Page 1 of 1

SQL Error?

Posted: Fri Jan 22, 2010 8:36 am
by Paws
Hey, I am having trouble with the following sql query...

Code: Select all

$query = mysql_query("INSERT INTO `orders` (`order_status`,`productcode` ,`dispatch_date` ,`customer_id`) VALUES ('Ordered', '$item', '$date', '$email'") or trigger_error(mysql_error());
I am getting the error...
Notice: 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 in /home/spadean1/public_html/john/order.php on line 46
Any help appreciated.

Thanks

Re: SQL Error?

Posted: Fri Jan 22, 2010 8:51 am
by aravona
`orders` should be orders, you dont need quotes around your table name.

http://www.w3schools.com/SQl/sql_insert.asp

Re: SQL Error?

Posted: Fri Jan 22, 2010 12:49 pm
by SimpleManWeb
I don't see anything wrong with that sql statement. Have you tried executing this query directly into your database using phpmyadmin? You may get more detailed information about the error there.
`orders` should be orders, you dont need quotes around your table name.
Although the "`" around the table name is not necessary, it is not an error. In fact, many people will tell you that it's good programming practices to always use the table name in "`". It is very helpful when doing large sql statements.

Hope this helps