【发布时间】:2016-07-31 06:57:44
【问题描述】:
我正在尝试通过提交表单来插入数据,这是我得到的错误
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 'desc,refno,quantity,imgname, image)
VALUES('name','Some desc ', '123','123' at line 1
下面是我的sql查询
$query= mysqli_query($connect,
"INSERT INTO products(name,desc,refno,quantity)
VALUES('$names','$productdesc', '$refno','$quanitity')");
如果我打电话给print_r 这就是我得到的
Array
(
[name] => name
[refno] => 123
[quantity] => 123456
[description] => Some desc
[submit] => Add Product
)
【问题讨论】:
-
DESC 是保留字,使用反引号,`desc`
-
或者,最好不要使用 desc
标签: php mysql sql mysqli syntax-error