mysql_num_rows希望参数1是寄存器形式为[duplicate]的资源错误消息

问题描述

|                                                                                                                   这个问题已经在这里有了答案:                                                      

解决方法

        检查查询是否正确,然后对行进行计数。
//select all rows from our users table where the emails match
$res1 = mysql_query(\"SELECT * FROM `userloginl.email`,`userlogin_fb.email` WHERE `email` = \'\".$email.\"\'\");

// checks if results where return without any errors
if(!$res1){
    die(\'There was an error in query \'. mysql_error());
}

$num1 = mysql_num_rows($res1);

//if the number of matchs is 1
if($num1 == 1){
    //the email address supplied is taken so display error message
    echo \"<center>The <b>e-mail</b> address you supplied is already taken</center>\";
    include_once (\"resources/php/footer.php\");      
    exit;   
}else{
    //finally,otherwise register there account
}
在您的情况下,脚本将为
die()
。检查是什么导致它死亡并修复它。通常,您必须始终检查查询是否返回
true
false
,然后对其进行处理     ,        您的查询无效,导致查询失败。您正在从两个不同的能力中选择一个\'email \'字段,但是没有在WHERE子句中提供表格,因此
where email = xxx
是不明确的。     ,        处理查询时出错。 使用
mysql_errno([$con])
mysql_error([$con])
得到错误。
if (!$res1) {
    die(\'Invalid query: \' . mysql_error());
}
仅将die用于调试,登录生产。否则,您可能会使它对SQL Injection不利。 (也许仍然很麻烦,但是那是盲SQL注入,这很难实现)