获取简单的mysql插入错误

时间:2011-04-03 00:10:58

标签: mysql sql mysql-error-1064

INSERT INTO `comments` 
  ( `id`, `pid`, `comment`, `user`, `date`, `active`) 
VALUES 
   ('23','3','Most Excellent!  I am using it right now as you can see and would never even consider different shopping cart software... I''ve tried them all and found them lacking the freedom to do it my way ;)','Admin','2010-12-08 21:00:07','1');

错误

  

您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在“最优秀”附近使用正确的语法!我正在使用它,因为你可以看到,甚至永远不会在第1行

让我感到困惑?!我替换了“我已经”的单引号,我仍然得到错误

  • PHP 5.3.6
  • Mysql 5.5.10

    DROP TABLE IF EXISTS `comments`;
    CREATE TABLE `comments` (
      `id` int(11) NOT NULL auto_increment,
      `pid` int(11) NOT NULL,
      `comment` varchar(255) NOT NULL,
      `user` varchar(25) DEFAULT '0',
      `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
      `active` tinyint(1) NOT NULL DEFAULT '0',
      PRIMARY KEY (id)
    ); 
    

1 个答案:

答案 0 :(得分:0)

如果我以这种方式破解查询,我可以得到完全相同的错误:

INSERT INTO `comments` ( `id`, `pid`, `comment`, `user`, `date`, `active`) VALUES ('23','3','Most Excellent!  I am using it right now as you can see and would never even co

(在MySql 5.1.41上测试。)

我猜包含查询的字符串在179~180位被破坏。尝试在查询执行之前检查PHP代码中的查询字符串。