【发布时间】:2012-08-30 15:10:25
【问题描述】:
这真的不是我的第一个 SQL 查询;),但是......!,我有一个奇怪的错误: 我正在从 CSV 文件导入数据库,查询返回 mysql_query 的错误,在 phpmyadmin 中,如果我复制/粘贴查询,一切正常.
$result = mysql_query ($ sql);
echo $ sql. "=>". $result. ','. Mysql_error ($this-> cnx). '<br> cnx ='. $this-> cnx. '<br>';
在回声中:
INSERT INTO tiny_url (`id`, `url`, `tiny_url`, `page_rank`, `link_name`, `destination_url`, `anchor`, `active`) VALUES (NULL, "111", "222", 3, "444", "555", 1,1)
=>, 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 '
'At line 3
cnx = Resource id # 27
如果我这样做:它有效:
$sql = 'INSERT INTO tiny_url (`id`, `url`, `tiny_url`, `page_rank`, `link_name`, `destination_url`, `anchor`, `active `) VALUES (NULL," 111 "," 222 ", 3," 444 "," 555 ", 1,1) ';
$result = mysql_query ($sql);
echo $sql. "=>". $result. ','. mysql_error($this-> cnx). '<br> cnx ='. $this-> cnx. '<br>';
你能帮帮我吗?
工厂
【问题讨论】:
-
您可以为您的表显示 CREATE TABLE 吗?
-
可以分享一下涉及$this->cnx的代码吗?您似乎正在尝试包含对象或资源而不是数字?
-
INSERT中的整数周围是否有空格?...VALUES (NULL," 111 "," 222 "...
标签: php mysql phpmyadmin