我得到一个语法错误是我的mysqli_query的PHP代码

时间:2014-12-24 17:07:15

标签: php mysql mysqli

我收到语法错误,但对我而言似乎是正确的代码,但得到了:

  

解析错误:语法错误,意外';'在第121行的C:\ xampp \ htdocs \ orlando \ php \ processor \ processor.php

我的代码是:

    $sql_new = mysqli_query($conn, 
        'SELECT * FROM
        products_added
        where username = "'.mysqli_real_escape_string($conn, $_SERVER['REMOTE_ADDR'].'"
        ORDER BY id asc'
    );

4 个答案:

答案 0 :(得分:3)

您在mysqli_real_escape_string上留下了右括号。

$sql_new = mysqli_query($conn, 
    'SELECT * FROM
    products_added
    where username = "' .mysqli_real_escape_string($conn, $_SERVER['REMOTE_ADDR']) . '"
    ORDER BY id asc'
);

答案 1 :(得分:1)

在此行中缺少)

where username = "'.mysqli_real_escape_string($conn, $_SERVER['REMOTE_ADDR'].'"

应该是:

 where username = "'.mysqli_real_escape_string($conn, $_SERVER['REMOTE_ADDR']).'"

答案 2 :(得分:0)

您在查询

中错过了最后)
'SELECT * FROM products_added
 where username = "'.mysqli_real_escape_string($conn, $_SERVER['REMOTE_ADDR']).'"
 ORDER BY id asc'

答案 3 :(得分:0)

$sql_new = mysqli_query($conn, 
        'SELECT * FROM
        products_added
        where username = "'.mysqli_real_escape_string($conn, $_SERVER['REMOTE_ADDR']**)**.'"
        ORDER BY id asc'
);

添加此支架,此处以粗体显示..