Page 1 of 1

Error that doesn't exist!!!! <---------------------

Posted: Tue Jan 30, 2007 11:32 pm
by ykarmi
Hey guys,
I get the following error:

Code: Select all

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 ''fname', 'lname', 'address', 'city', 'zipcode', 'amount') VALUE: INSERT INTO tbuserinfo ('fname', 'lname', 'address', 'city', 'zipcode', 'amount') VALUES (John, Doe, 1 Main St, San Jose, 95131, 1.00)

Here's my original line:

Code: Select all

$query = "INSERT INTO tbuserinfo ('fname', 'lname', 'address', 'city', 'zipcode', 'amount') VALUES ($firstName, $lastName, $address1, $city, $zip, $amount)";
Can you spot anything wrong with it? Because I can't :S
Thanks a lot!
Yuval :D

Posted: Wed Jan 31, 2007 12:06 am
by Kieran Huggins
It's the quotes -- use backticks (above the left tab key) for field names (if anything), and single quotes for variables:

Code: Select all

$query = "INSERT INTO tbuserinfo (`fname`,`lname`,`address`,`city`,`zipcode`,`amount`) VALUES ('{$firstName}','{$lastName}','{$address1}','{$city}','{$zip}','{$amount}')";

Posted: Wed Jan 31, 2007 12:16 am
by Luke
also, please don't add <------------------------------ to your thread title. This is not going to get people to respond sooner. This community responds very fast as it is. More than likely this will only irritate people.