mysqli_query(): Couldn't fetch mysqli
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
出現以上的的錯誤,
<?php
require_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;
? ?}
}
? ?//print_r($data);
?>
代碼沒錯啊
2017-07-05
可能是$query = mysqli_query($con,$sql);這一句的錯誤,把sql語句放數據庫里驗證是否正確