duanbo5230 2015-09-30 11:18
浏览 19

从db [duplicate]中选择时出现MySQLi语法错误

This question already has an answer here:

I'm getting a syntax error with this block of code, and I have no idea why. Here is the specific error itself: "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 'match ORDER BY id DESC' at line 1"

Here is the PHP code block:

        $bbcode = new BBCode;

        $sql = "SELECT * FROM match ORDER BY id DESC";

        $res = mysqli_query($dbCon, $sql) or die(mysqli_error($dbCon));

        $match = "";
</div>
  • 写回答

1条回答 默认 最新

  • donglin317704291 2015-09-30 11:20
    关注

    MATCH is a reserved keyword in mysql: https://dev.mysql.com/doc/refman/5.0/en/keywords.html

    To make your code working change your query to:

    $sql = "SELECT * FROM `match` ORDER BY id DESC";
    
    评论

报告相同问题?