John AJ
John AJ

Reputation: 21

PHP MySQL issue with INSERT INTO

$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?

Upvotes: 0

Views: 46

Answers (1)

John Woo
John Woo

Reputation: 263933

you don't need VALUES() here

INSERT INTO first_name
SELECT first_name 
FROM people WHERE fname = '$fname'

Upvotes: 2

Related Questions