user1178177
user1178177

Reputation: 27

You have an error in your SQL syntax; check the manual that corresponds and etc

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

Upvotes: 1

Views: 5860

Answers (3)

dgw
dgw

Reputation: 13646

DESCRIBE is a Mysql keyword. See the documentation.

Upvotes: 0

palAlaa
palAlaa

Reputation: 9858

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());

Upvotes: 0

drew010
drew010

Reputation: 69967

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.

Upvotes: 7

Related Questions