0
$SQL="INSERT INTO first_name VALUES (fname) SELECT first_name FROM people WHERE fname = '$fname'";

I'm trying to insert the value 'fname' which is $fname (variable defined by a user) into the column 'first_name'

It's not adding anything but not displaying any errors. Syntax problem?

5
  • Is your table name first_name? Commented Dec 17, 2013 at 21:57
  • 2
    mysql_error is the function for returning errors in your query. If I have to read one more post about this I am going to scream. Commented Dec 17, 2013 at 21:57
  • Are you saving the same value in 2 different tables? Commented Dec 17, 2013 at 21:58
  • As another aside, it's highly unsafe to just stick that ol' $fname into the query. Since you're using it, I'm assuming that you're using the mysql_* family of functions, which is BAD. The question that I just linked also has resources on alternatives. Commented Dec 17, 2013 at 22:01
  • possible duplicate of Wrong syntax for Mysql? Commented Dec 17, 2013 at 22:06

1 Answer 1

2

you don't need VALUES() here

INSERT INTO first_name
SELECT first_name 
FROM people WHERE fname = '$fname'
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.