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

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

问题描述

我正在我的网站内建立一个搜索.我的数据库有问题.它给了我这个:

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 服务器版本相对应的手册,以获取正确的语法,以使用接近 'titch LIKE "%tags%" 的语法.ORDER BY id_dreams DESC' 在第 1 行

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 查询可能失败,并且您返回的是 false 而不是 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.

您是否检查过您的查询?

Have you checked your query?

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

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