Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 检查数据库中是否存在用户_Php_Mysql_If Statement_Exists - Fatal编程技术网

Php 检查数据库中是否存在用户

Php 检查数据库中是否存在用户,php,mysql,if-statement,exists,Php,Mysql,If Statement,Exists,我有一个问题,我不知道为什么这个不运行 $fb_id = $db->real_escape_string($fb_id); $result = $db->query("select id,fb_id from users where fb_id='$fb_id'"); if (mysql_num_rows($result) > 0) { echo "user exist"; } else { echo "u

我有一个问题,我不知道为什么这个不运行

$fb_id = $db->real_escape_string($fb_id);
        $result = $db->query("select id,fb_id from users where fb_id='$fb_id'");
        if (mysql_num_rows($result) > 0) {
            echo "user exist";
        } else {
echo "user dont exist";
        }
有一个错误

Warning: mysql_num_rows() expects parameter 1 to be resource, object given in 94
但在第94行我有

if (mysql_num_rows($result) > 0) {

感谢您的帮助

Yes看起来您正在使用某个mysql类进行查询操作$db是该类的一个实例。签入该类您可能有一些函数来获取num rows,比如get_num_rows(),您可以使用$db->get_num_rows()…当我更改它时,您如何说没有方法致命错误:调用未定义的方法mysqli::get_num_rows()在第94行的/data/web/virtuals/47683/virtual/www/subdom/test/callback.php中,我将其用于connect to db$db=mysqli_connectoh,您使用了我提到的文字函数名。我要求检查$db类,看看是否有返回行数的方法,我只是给了你一个例子。