【问题标题】:MySQL Error - Inserting into TableMySQL 错误 - 插入表中
【发布时间】:2012-10-14 20:12:32
【问题描述】:

我在插入表格时遇到了一点问题,代码如下:

mysql_query("INSERT INTO admin_menu (id, title, type, icon, parent, url, order, append, module) VALUES('', 'powerpoint', '0', 'powerpoint.png', '0', 'powerpoint/config', '0', '0', '0' ) ") or die(mysql_error()); 

它给了我以下错误:

您的 SQL 语法有错误;检查手册 对应于您的 MySQL 服务器版本,以便使用正确的语法 靠近'订单,附加,模块)值('','powerpoint','0', 'powerpoint.png', '0', 'pow' 在第 1 行

任何帮助将不胜感激,谢谢!

【问题讨论】:

    标签: php mysql insert


    【解决方案1】:

    orderreserved word。用反引号括起来

    ... url, `order`, append,...
    

    你也不应该使用mysql_query

    不鼓励使用此扩展程序。相反,应该使用 MySQLi 或 PDO_MySQL 扩展。

    【讨论】:

      【解决方案2】:

      您需要使用反引号。 order 是保留关键字。

      mysql_query("INSERT INTO admin_menu (id, title, type, icon, parent, url, `order`, append, module)
      

      【讨论】:

        猜你喜欢
        • 2017-03-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-01
        • 2011-08-12
        • 2013-06-17
        • 2016-07-30
        相关资源
        最近更新 更多