挣扎着我的网页设计任务.我一直在按照教程为我的网站添加搜索功能,但我一直收到以下错误:
警告:mysqli_num_rows()要求参数1为mysqli_result,第31行的/search.php中给出布尔值
第31行是(或是)
<pre>if(mysqli_num_rows($results) >= 1)</pre>
Run Code Online (Sandbox Code Playgroud)
那是原来的错误.根据评论中的说明,我已经修改了代码:
<pre>
<?php
//capture search term and remove spaces at its both ends if the is any
$searchTerm = trim($_GET['keyword']);
//check whether the name parsed is empty
if($searchTerm == "")
{
echo "Enter the name/brand of what you're looking for.";
exit();
}
//database connection info
$host = "localhost";
$db_name = "sookehhh_shopsy_db";
$username = "sookehhh_shopsy";
$password = "xxxx";
//connecting to server and creating link to database
$link = mysqli_connect($host, $username, $password, $db_name) or die('Could not …Run Code Online (Sandbox Code Playgroud)