可能 SQL 语法错误

Probably SQL syntax error

你好,我不知道我的错误是否清楚如果我打开我的网站,我会在左边的床Sql语法这里是我的代码

    <?php

$db_user = "root";
$db_pass = "";
$db_name_gs = "l2jgs";
$db_name_ls = "l2jls";
$db_name_cs = "l2jcs";
$db_serv = "127.0.0.1";
$res = mysqli_connect ( $db_serv, $db_user, $db_pass ) or die ("Coudn't connect to [$db_serv]");
    $resdb = mysqli_select_db ( $res, $db_name_gs ) or die (mysqli_error("Cannot connect to Game Server"));
    $resdb = mysqli_select_db ( $res, $db_name_ls ) or die (mysqli_error("Cannot connect to Login Server"));
    $resdb = mysqli_select_db ( $res, $db_name_cs ) or die (mysqli_error("Cannot connect to Community Server"));
$query=("SELECT * FROM characters WHERE pvpkills > 0 AND accesslevel = 0 ORDER BY pvpkills DESC LIMIT 50");
echo"<html><head></head><body bgcolor='#000000' style='color:rgb(200,200,200)'>";
echo "<table  border='2' align=center width=440>";
echo "<tr><th>Nr</th><th>Name</th><th>PvP Kills</th><th>Main class</th><th>Status</th></tr>\n";
if ($result=mysqli_query($res,$query)or die("Bed Sql syntax")) {
  $nr=1;
while ($row=mysqli_fetch_row($result)) {
     echo "<tr><td align=center>".$nr."</td>";
     $nr++;
    echo "<td align=center>".$row[0]."</td>";
    echo "<td align=center>".$row[1]."</td>";
    echo "<td align=center>".$row[2]."</td>";
    if($row[4]==0)
    {   
        if($row[3])
        {echo "<td align=center style='color:rgb(0,255,0)'>Online</td></tr>\n"; }
         else{echo "<td align=center style='color:rgb(255,0,0)'>Offline</td></tr>\n";}
    }
     else{echo "<td align=center style='color:rgb(255,0,0)'>Hidden</td></tr>\n";}
}
}else{ echo "<!-- SQL Error ".mysql_error()." -->";}

echo "</table></body></html>";


?>

抱歉,如果它已经翻倍了 post,但我没有看到任何符合我的问题的 post 谢谢大家 :)

要捕获通过 PHP 在 MySql 数据库中执行操作时遇到的确切错误,您始终可以使用 mysqli_error()

The mysqli_error() function returns the last error description for the most recent function call, if any.

了解更多信息 here

面向对象风格 string $mysqli->error;

程序风格 string mysqli_error ( mysqli $link )