mysql_num_row():提供的参数不是有效的MySQL结果资源

时间:2012-01-30 12:52:41

标签: php mysql-num-rows

我不知道为什么会出现此错误:mysql_num_row():supplied argument is not a valid MySQL result resource

$sqlCheckLevel = 'SELECT * FROM levelPerClass WHERE clsId = \''.$class.'\' AND lvlId = \''.$rowLevel['lvlId'].'\'';
$resCheckLevel = mysql_query($sqlCheckLevel);
print_r($rowCheckLevel = mysql_fetch_assoc($resCheckLevel));
//prints 'Array ( [clsId] => 15 [lvlId] => 18 )'    

if(mysql_num_rows($rowCheckLevel) == 0) {
    //etc

有什么问题?

修改 我觉得我好笨。 它必须是

 if(mysql_num_rows($resCheckLevel) == 0) {

1 个答案:

答案 0 :(得分:2)

使用like,

mysql_num_rows($resCheckLevel)而不是

mysql_num_rows($rowCheckLevel)