使用mysqli_num_rows()PHP时出错

时间:2014-02-12 19:53:04

标签: php

我的脚本在我的本地计算机上运行完全正常,但是当我把它放在我的服务器上时,我收到错误:

错误:

mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given

我的PHP:

$connect= mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
or die('error connecting to the database,');

$username= $_POST['username'];
$username= mysqli_real_escape_string($connect, $username);

$username_check_query= "SELECT * FROM users WHERE username= '".$username."'";
$username_check_result= mysqli_query($connect, $username_check_query)
    or die('Error with the username check query');

if (mysqli_num_rows($username_check_result) != 0) {

    echo "1";

}

我完全无法解决这个问题。为什么这会在我的localhost上运行,但在实时服务器上抛出错误?只是为了澄清,我不会在查询本身中出错。

0 个答案:

没有答案