数据库错误:MySQL错误号:1064

时间:2014-01-12 08:30:15

标签: php mysql sql codeigniter

我不能为我的生活弄清楚这里的问题是什么,也许另外一双眼睛可能有帮助:

以下是错误消息:

Error Number: 1064

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 '://www.amazon.com/Lemon-Recipes-Alkalizing-Addition-Delectable-ebook/dp/B00CZTCS' at line 1

INSERT INTO `books` (`asin`, `keyword_id`, `page_count`, `sales_rank`, `price`, `link`) VALUES (B00CZTCS9K, 1, 77, 96317, 2.25, http://www.amazon.com/Lemon-Recipes-Alkalizing-Addition-Delectable-ebook/dp/B00CZTCS9K%3FSubscriptionId%3DAKIAJPNAWJHXGB5IYXOA%26tag%3Dgenroad-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB00CZTCS9K)

3 个答案:

答案 0 :(得分:1)

正如 M Khalid Junaid 所提到的,你需要在单引号中包装字符串。 这意味着'B00CZTCS9K'和链接'http://....'都应该被包装。

其余的看起来像小数,但是,如果任何其他值是一个字符串(varchar)而不是包装它。

答案 1 :(得分:0)

尝试此操作,为'列值添加asin and link引号,这些值是字符串。字符串需要用引号括起来。

  INSERT INTO `books` (`asin`, `keyword_id`, `page_count`, `sales_rank`, `price`, `link`) 
  VALUES ('B00CZTCS9K', 1, 77, 96317, '2.25', 'http://www.amazon.com/Lemon-Recipes-Alkalizing-Addition-Delectable-ebook/dp/B00CZTCS9K%3FSubscriptionId%3DAKIAJPNAWJHXGB5IYXOA%26tag%3Dgenroad-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB00CZTCS9K')

答案 2 :(得分:0)

您需要在所有字符串周围加上引号,包括网址:

INSERT INTO `books` (`asin`, `keyword_id`, `page_count`, `sales_rank`, `price`, `link`) 
VALUES ('B00CZTCS9K', 1, 77, 96317, '2.25', 'http://www.amazon.com/Lemon-Recipes-Alkalizing-Addition-Delectable-ebook/dp/B00CZTCS9K%3FSubscriptionId%3DAKIAJPNAWJHXGB5IYXOA%26tag%3Dgenroad-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB00CZTCS9K')

否则,mySQL会抛出错误,因为它试图将文本解析为列或mySQL结构。