您的SQL语法有错误; 检查对应的手册等

use*_*177 1 php mysql mysql-error-1064

我疯了,我想在东西tabale中插入一个值,但我得到这个错误

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
Run Code Online (Sandbox Code Playgroud)

我的代码是:

mysql_query("insert into stuff(name,describe,price,picname) values ('dfg','dfgdf','2','hr')") or die("cannot execute the query" .mysql_error());
Run Code Online (Sandbox Code Playgroud)

我能做什么 ?它浪费了我1个小时的工作!谢谢

dre*_*010 7

mysql_query("insert into stuff (`name`,`describe`,`price`,`picname`) values ('dfg','dfgdf','2','hr')") or die("cannot execute the query" .mysql_error());
Run Code Online (Sandbox Code Playgroud)

将列名括在反引号中,因为它describe是一个保留字.

  • +1.但最好不要使用保留字作为字段名称 (3认同)