我正在实施搜索功能,我收到此错误
警告:mysqli_error()需要1个参数,0在第18行的C:\ xampp \ htdocs \ Tickmill Auction Project \ search.php中给出
我在xampp上使用php 7.0。
<?php
$conn = mysqli_connect("localhost", "root", "", "tickmill_auctions");
if(mysqli_connect_error()){
echo "Failed to connect: " .mysqli_connect_error();
}
$output = '';
if (isset($_GET['q']) && $_GET['q'] !== ' ') {
$searchq = $_GET['q'];
$q = mysqli_query($conn, "SELECT * FROM images WHERE keywords LIKE '%$searchq%' OR title LIKE '%$searchq%'") or die(mysqli_error());
$c = mysqli_num_rows($q);
if($c == 0){
$output = 'No search results for <b>"' . $searchq . '"</b>';
} else {
while ($row = mysqli_fetch_array($q)){
$artist = $row['artist'];
$title = $row['title'];
$file = $row['file_name'];
$output .= '<a href "' . $title . '">
<h3>' . $artist . '</h3>
<p>' . $desc . ' </p>
</a>';
}
}
} else {
header("Location: ./");
}
print ("$output");
mysqli_close($conn);
?>
答案 0 :(得分:0)
使用此选项,您必须将Connection对象传递给mysqli_error()
die(mysqli_error($conn))
关于mysqli_error()
mysqli_error()函数返回最近一次函数调用的最后一个错误描述(如果有的话)。
<强>语法强>
mysqli_error(connection);