0

我收到的错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 6 行的 'release= 2012-09-02, platforms= Android, link=`play.php?game=G'附近使用正确的语法

编码:

$sql = "UPDATE
            GameInformation
        SET
            keyIndex=`GameTest`,
            name=`Game Test`,
            release=`2012-09-02`,
            platforms=`Android`,
            link=`play.php?game=GameTest`,
            icon=`img/thumb_gametest.png`,
            thumb=`img/thumb_mini_gametest.png`,
            swf=`swf/GameTest.swf`,
            height=`500`,
            width=`920`
        WHERE
            keyIndex=`GameTest2`";

$query = mysql_query($sql);

if (!$query) exit (mysql_error());

我一直在我的设置变量周围尝试不同的分隔符(大括号、撇号、引号)但无济于事。这里有保留字吗?

更新 [已解决],更正代码:

$sql = 'UPDATE
                            `GameInformation`
                        SET
                            `keyIndex`="GameTest",
                            `name`="Game Test",
                            `release`="2012-09-02",
                            `platforms`="Android",
                            `link`="play.php?game=GameTest",
                            `icon`="img/thumb_gametest.png",
                            `thumb`="img/thumb_mini_gametest.png",
                            `swf`="swf/GameTest.swf",
                            `height`="500",
                            `width`="920"
                        WHERE
                            `keyIndex`="GameTest2"';
            $query = mysql_query($sql);
            if (!$query) exit (mysql_error());
4

2 回答 2

5

您应该使用 ` 作为表名和列名,使用 " 或 ' 作为内容。RELEASE 是保留字

UPDATE
            `GameInformation`
        SET
            `keyIndex`="GameTest",
            `name`="Game Test",
            `release`="2012-09-02",
            `platforms`="Android",
            `link`="play.php?game=GameTest",
            `icon`="img/thumb_gametest.png",
            `thumb`="img/thumb_mini_gametest.png",
            `swf`="swf/GameTest.swf",
            `height`="500",
            `width`="920"
        WHERE
            `keyIndex`="GameTest2"
于 2012-10-10T20:22:32.277 回答
0

release是mysql中的保留字。

http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

于 2012-10-10T20:23:15.463 回答