警告:mysql_fetch_array() 期望参数 1 是资源,布尔值在 [英] Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in

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

问题描述

可能的重复:
PHP:警告:sort() 需要参数 1为数组,给定资源

请帮忙,

我收到以下错误:

警告:mysql_fetch_array() 期望参数 1 是资源,布尔值在......

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in......

这是我的查询:

$query = "SELECT ListNumber FROM residential"; 
$result1 = mysql_query($query); 
    if (mysql_num_rows($result1) >10){ 
        $difference = mysql_num_rows($result1) - 10; 
        $myQuery = "SELECT * FROM `residential` ORDER BY `id` LIMIT 10,". $difference; 
        $result2 = mysql_query($myQuery); 
echo $result2;
        $replace =  str_replace(", "," | ", $result2);
    while ($line = mysql_fetch_array($result2, MYSQL_BOTH))

推荐答案

您的查询 ($myQuery) 失败,因此不会生成查询资源,而是生成 FALSE.

Your query ($myQuery) is failing and therefore not producing a query resource, but instead producing FALSE.

要显示动态生成的查询的外观并显示错误,请尝试以下操作:

To reveal what your dynamically generated query looks like and reveal the errors, try this:

$result2 = mysql_query($myQuery) or die($myQuery."<br/><br/>".mysql_error());

错误消息将引导您找到解决方案,根据您下面的评论,该解决方案与在您从中选择的表中不存在的字段上使用 ORDER BY 相关.

The error message will guide you to the solution, which from your comment below is related to using ORDER BY on a field that doesn't exist in the table you're SELECTing from.

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

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