这在一秒前是有效的。我无论如何也找不出哪里出了问题。
错误:警告: mysqli_fetch_array()要求参数1为mysqli_result,布尔值在第25行的C:\xampp\htdocs\PhpProject1\results.php中给定
<!DOCTYPE HTML>
<html>
<head>
<link type="text/css" rel="stylesheet" href="Stylesheet.css"/>
<title>Find Me the Goods</title>
</head>
<body>
<a href="form.php" id="help">Help other people find the goods</a>
<div class="container">
<?php
Error:Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\PhpProject1\results.php on line 25
require("config.php");
if(isset($_POST['submit'])){
$searchTerm = $_POST['searchTerm'];
}
$result = mysqli_query($dbConn,"SELECT * FROM input WHERE country or region or townCity = '$searchTerm'");
while($row = mysqli_fetch_array($result))
{
echo"<div id=resultsbox>";
echo "<p id='date'>" . $row['theDate'] . "</p>";
echo "<table border='0' id='resultsTable'>";
echo "<tr><td><span>" . $row['townCity'] . "</span></td></tr>";
echo "<tr><td>" . $row['region'] . "</td></tr>";
echo "<tr><td>" . $row['country'] . "</td></tr>";
echo "</table>";
echo "<h1>Public smoking tolerance:" . " " . $row['tolerance'] . "/5</h1>";
echo "<h1>Relevant Laws:</h1><p>" . $row['laws'] . "</p>";
echo "<h1>Where to go to find it:</h1><p>" . $row['whereFind'] . "</p>";
echo "<h1>What to expect to pay:</h1><p>" . $row['price'] . "</p>";
echo "<h1>Addition information:</h1><p>" . $row['information'] . "</p>";
echo"</div>";
}
?>
</div>
</body>
</html>发布于 2013-10-07 10:36:31
这个错误仅仅意味着MYSQLI返回了一个空的结果集。在while循环之前,您应该添加:
if(empty($result)){
echo "No results were found.";
}else{
// while loop goes here
}只要确保你的MYSQLI查询是安全的,只需要做一些阅读。下面是一些有用的堆栈溢出源:
https://stackoverflow.com/questions/19216250
复制相似问题