我正在尝试在线显示用户列表。而且我有一个 sql,但在我的页面上它说“您的 SQL 语法有错误;请检查与您的 MySQL 服务器版本相对应的手册,以便在第 8 行的 '' 附近使用正确的语法”,我想知道怎么做我显示没有任何错误的用户列表。
<?php $sql = "SELECT
        user_id,
        user_name,          
        online
    FROM
        users
    WHERE
        user_id = " . mysql_real_escape_string($_GET['id']);
$result = mysql_query($sql);
if(!$result)
{
echo 'There are currently no user online.' . mysql_error();
}
else
{
if(mysql_num_rows($result) == 0)
{
    echo 'There are currently no user online.';
}
else
{
    //display category data
    while($row = mysql_fetch_assoc($result))
    { $D= $row['online']; 
    if( ($D) !=1)
    {
    echo 'There are currently no user online.';
}
else
{ 
         echo'<a href="/index.php?area=profile&userid=' .   $posts_row['user_id'] . '" class="topicuser_member"><span ' . $posts_row['user_class'] .  '>' . $posts_row['user_name'] . '</span></a>,';}}}}?>