html - Issue accessing results with PHP from an SQL database which was working yesterday. Also, need advice for injection proofing -
this question has answer here:
this working second ago. can't life of me figure out went wrong.
error: warning: mysqli_fetch_array() expects parameter 1 mysqli_result, boolean given in c:\xampp\htdocs\phpproject1\results.php on line 25
<!doctype html> <html> <head> <link type="text/css" rel="stylesheet" href="stylesheet.css"/> <title>find me goods</title> </head> <body> <a href="form.php" id="help">help other people find goods</a> <div class="container"> <?php error:warning: mysqli_fetch_array() expects parameter 1 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 * input 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 go find it:</h1><p>" . $row['wherefind'] . "</p>"; echo "<h1>what expect pay:</h1><p>" . $row['price'] . "</p>"; echo "<h1>addition information:</h1><p>" . $row['information'] . "</p>"; echo"</div>"; } ?> </div> </body> </html>
that error means mysqli returned empty result set. before while loop, should add:
if(empty($result)){ echo "no results found."; }else{ // while loop goes here }
as far making sure mysqli queries secure goes, bit of reading. here few useful stack overflow sources:
Comments
Post a Comment