警告:mysqli_query()至少需要2个参数,给定1个(再次发生此错误)

时间:2019-06-09 05:34:30

标签: php html

何时得到此错误。正在运行搜索...

  

警告:mysqli_num_rows()期望参数1为mysqli_result,   在/storage/ssd2/966/9873966/public_html/main.php中给出的null   16

$query = mysqli_query("SELECT * FROM members WHERE fname LIKE '%$searchq%'");

$count = mysqli_num_rows($query);

1 个答案:

答案 0 :(得分:0)

您需要将连接作为第一个参数传递给数据库mysqli_query。

使用mysqli_connect

创建连接

示例

$conn=mysqli_connect("localhost","my_user","my_password","my_db");
$query = mysqli_query($conn, your_query_here)

验证查询是否正确运行:

if($result = mysqli_query($conn, your_query_here) {
// do whatever you want with the result
} else {
echo mysqli_error($conn);
}