Page 1 of 1
mysql insert error
Posted: Wed Mar 28, 2007 10:58 pm
by pinehead18
Code: Select all
mysql_query("INSERT INTO newsletter (first_name, last_name, email, birthday) VALUES ($first_name, $last_name, $email, $birthday)") or die(mysql_error());
thats my code.
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ' , , )' at line 1
thats my error
Any idea?
Thanks
Re: mysql insert error
Posted: Thu Mar 29, 2007 12:42 am
by Christopher
Quote your strings, and remember to escape the values before building the SQL (mysql_real_escape_string()):
Code: Select all
mysql_query("INSERT INTO newsletter (first_name, last_name, email, birthday) VALUES ('$first_name', '$last_name', '$email', '$birthday')") or die(mysql_error());
Posted: Thu Mar 29, 2007 3:26 am
by s.dot
What aborint said, or one of these values isn't set. "$first_name, $last_name, $email, $birthday"