Iam going crazy , i want to insert a value in stuff tabale but i get this error
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 'name,describe,price,picname) values ('dfg','dfgdf','2','hr')' at line 1
my code is :
mysql_query("insert into stuff(name,describe,price,picname) values ('dfg','dfgdf','2','hr')") or die("cannot execute the query" .mysql_error());
What can i do ? it waste 1 hour of my work ! Thanks
mysql_query("insert into stuff (`name`,`describe`,`price`,`picname`) values ('dfg','dfgdf','2','hr')") or die("cannot execute the query" .mysql_error());
Enclose your column names in backticks since describe
is a reserved word.
It's an error in SQL, you can copy this sql statement and execute it in My SQL directly and check it out.
The problem may be in the single qoutes of 2 since it's number.
mysql_query("insert into stuff(name,describe,price,picname) values ('dfg','dfgdf',2,'hr')") or die("cannot execute the query" .mysql_error());
DESCRIBE
is a Mysql keyword. See the documentation.