mysql_num_rows()期望参数1为资源,布尔值在 [英] mysql_num_rows() expects parameter 1 to be resource, boolean given in

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

问题描述

可能重复:
警告:mysql_num_rows()期望参数1为资源,

Possible Duplicate:
Warning: mysql_num_rows() expects parameter 1 to be resource,

我是这个论坛的新手. 我正在网站上进行搜索. 我的数据库有问题.给我这个:

I'm new in this forum. I'm building a search within my site. I have a problem with the DB. It's giving me this:

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\EasyPHP-5.3.5.0\www\searchscript\search.php on line 86

我将向您展示在代码部分中出现此类错误的地方

I'll show you the code section where it gives me such error

line 82: $query = "SELECT * FROM dreams WHERE titolo,titch LIKE \"%$trimmed%\" ORDER BY id_dreams DESC "; 
line 85: $numresults=mysql_query($query);
line 86: $numrows=mysql_num_rows($numresults); //error

现在,我试图查看查询背后的问题是什么,并且告诉我:

Now I tried to see what is the problem behind the query and it's telling me this:

SELECT * FROM dreams WHERE titolo, titch LIKE "%tags%" ORDER BY id_dreams DESC 

您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册以获取正确的语法,以在第1行的'titch LIKE%tags%" ORDER BY id_dreams DESC'附近使用

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'titch LIKE "%tags%" ORDER BY id_dreams DESC' at line 1

其背后的代码是:

$query = "SELECT * FROM dreams WHERE titolo, titch LIKE \"%$trimmed%\" ORDER BY id_dreams DESC "; 
$result = mysql_query($query) or die($query."<br/><br/>".mysql_error());

推荐答案

mysql_query返回一个布尔值,这意味着sql查询可能失败,并且您得到的是错误的返回值,而不是mysql资源.

The mysql_query is returning a boolean value meaning the sql query is probably failing and you're getting a false returned rather than a mysql resource.

您检查过查询吗?

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

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