警告:mysql_num_rows()期望参数1为资源,数组在 [英] Warning: mysql_num_rows() expects parameter 1 to be resource, array given in

查看:86
本文介绍了警告:mysql_num_rows()期望参数1为资源,数组在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我需要你的帮助.为什么会给我标题中提到的这个Errror错误,为什么呢?

Hey guys, I need your help. What can be my problem why its giving me this Errror as mentioned in the Title?

这是我的代码:

 if (!$connect){ 
        die("Failed to connect to the database: ".mysql_error()); 
    } 
$kies_bd = mysql_select_db("eraenz_db1",$connect); 
    if (!$kies_bd){ 
        die("failed to choose from BD: ".mysql_error()); 
    } 
$query = mysql_query("SELECT ListNumber FROM residential");// or die($myQuery."<br/><br/>".mysql_error()); 
$result1 =  mysql_fetch_assoc($query) or die($myQuery."<br/><br/>".mysql_error()); 
echo $result1;
    if (mysql_num_rows($result1) >10){ 
        $difference = mysql_num_rows($result1) - 10; 
        $myQuery = mysql_query("SELECT * FROM residential ORDER BY ListNumber LIMIT 10,". $difference) ; 

推荐答案

mysql_num_rows 函数接受资源标识符

在您的情况下为$query请注意,$result1是获取的数组,其中包含不应在此函数中传递的数据库数据.

in your case it is $query Note that $result1 is the fetched array and contain the data from database that should not be passed in this function.

mysql_num_rows($query)

我建议您在提出问题之前先阅读手册

And I would suggest you read the manual before asking quesions

这篇关于警告:mysql_num_rows()期望参数1为资源,数组在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆