Warning: mysql_num_rows() expects parameter 1 to be resource, object given in D:\wamp\www\2017-last class\NO-10-Mysql\article\admin\article.search.php on line 6以上的问题应该怎么解决呢,也打印不出数据代码出错的地方是以下:<?phprequire_once('../connect.php');$key = $_GET['key'];$sql = "select * from article where title like '%$key%' order by dateline desc";$query = mysqli_query($con,$sql);if($query&&mysqli_num_rows($query)){ while($row=mysqli_fetch_assoc($query)){ $data[]=$row; }}附:其他的都是这么用,就唯独这里出问题。。。
3 回答
已采纳
黄小凡
TA贡献69条经验 获得超36个赞
不知道你哪错了,感觉是数据库的查询出了问题,我帮你改成用mysqli类的方法,你试一下看看,我在我这用是没问题
<php $mysqli = new mysqli('localhost','root','root','test'); if ($mysqli->connect_errno) { die('connect error'); } $sql = "select * from article where title like '%$key%' order by dateline desc"; $mysqli_result = $mysqli->query($sql); if ($mysqli_result && $mysqli_result->num_rows>0) { while ($row = $mysqli_result->fetch_assoc()) { $data[] = $row; } } ?>
- 3 回答
- 0 关注
- 2831 浏览
添加回答
举报
0/150
提交
取消