【发布时间】:2012-12-05 21:12:45
【问题描述】:
我正在尝试在 PHP 中创建一些基本的插入查询,但它一直给我一个错误,但我真的不知道为什么,请各位大神看看有什么问题吗?
mysql_query("
INSERT INTO itens (nome, data, cliente, link, desc, img) VALUES ($nome,$data,$cliente,$link,$desc,$img)
") or die(mysql_error());
更新
从 OP 的已删除答案中提取,现在的代码是:
mysql_query("INSERT INTO itens (nome, data, cliente, link, `desc`, img)
VALUES ($nome,$data,$cliente,$link,$desc,$img)") or die(mysql_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 'kl,j)' at line 2
kl 和 j 是我在表格中插入的最后两件事。
【问题讨论】:
-
表名真的是
itens还是items? -
永远不要说“它给出了错误”。总是说“它给出了 this 错误”,然后粘贴实际错误。
-
对不起,错误是:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在 'desc, img) VALUES (s,2012-12-18,(nome, data, cliente, link, desc, img),ww' 附近使用的正确语法在第 1 行
-
它是 itens ,它的葡萄牙语
-
您的变量是字符串,但您没有在每个值周围加上引号;看看我的回答。