我通过php获得页面参数,组成一句sql语句如下:
insert into imgbook('id','author','title','desc','path') values (null,'dsrgsd','sfg','sdger','uploads/title.gif')在执行插入的时间总是报错:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server versio
 for the right syntax to use near ''id','author','title','desc','path') values (null,'dsrgsd','sfg','sdger','upload' at
line 1
各位大虾指点迷津。

解决方案 »

  1.   

    改为:
      insert into imgbook(id,author,title,desc,path) values (null,'dsrgsd','sfg','sdger','uploads/title.gif')
      数据库字段不要单引号!
      

  2.   

    我刚才也试过了,都不行。会不会在建数据库的时候选择表类型有关,如InnoDB。
    刚才也去试了一下
    mysql> insert into imgbook(id,author,title,desc,path) values (null,'tdfy54','dg54gf','rtdyg','uploads/title.gif');
    ERROR 1064 (42000): 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,path) values (null,'tdfy54','dg54gf','rtdyg','uploads/title.gif')' at line 1
      

  3.   

    insert into imgbook('id','author','title','desc','path') values (null,'dsrgsd','sfg','sdger','uploads/title.gif')
    这个错了,插入的字段不是用(')单引号,用的是键盘TAB键上面的那个(`),代码改成insert into `imgbook`(`id`,`author`,`title`,`desc`,`path`) values (null,'dsrgsd','sfg','sdger','uploads/title.gif')
    这样子一般就可以了,如果还不行就真有可能是数据类型问题了,建议把所以字段的类型都改成varchar(50),等测试通过再改回来!别忘记给分,我最近来自己就是为了分数
      

  4.   

    1 字段名不要加单引号
    2 看看ID是不是自动增加
    3 对“/”进行转意思再试试 即:insert into `contents`(`id`,`name`,`content`) values (null,'dsrgsd','uploads\/title.gif')
      

  5.   

    感谢life169的回复,但在试的过程中仍不行,不知是否还与其他有关请定夺                           谢谢   quronghua
      

  6.   


    insert into imgbook values (null,'dsrgsd','sfg','sdger','uploads/title.gif')你这样试试 看看有没有什么提示?
      

  7.   

    自增主键的可选项,可能为以下之一:‘’、null、0。与建表时的设置有关
    为避免书写的不规范,最好的做法是缺省主键项
    本身主键就是表示“唯一”,不具备任何实际意义