0

attach is my code for search.php but i have error on line 9, can someone pleasee help me to fix it ? Thnk you

XAMPP said
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\series\insert\Search.php on line 9

line 9 code:

while($row = mysql_fetch_array($results)){

below is my full code :

<?php
if($_GET){
$search=$_GET['search'];
$connect =mysql_connect("localhost","root","");
if($connect){
mysql_select_db("b_database",$connect);
$query = "SELECT * FROM b_database WHERE search='". $search . "'";
$results=mysql_query($query);
while($row = mysql_fetch_array($results)){
echo $row['isbn']. "<br/>". $row['title']. "<br/>";
}
}else{
die(mysql_error());
}
}
?>
<form action="" method="GET">
<table style=" border:1px solid silver" cellpadding="10px" cellspacing="0px" align="center">
<tr><td colspan="4" style="background:#0066FF; color:#FFFFFF; fontsize:20px">Search Record</td></tr>
<tr>
<td>Enter Search </td>
<td><input type="text" name="search" size="40" /></td>
<td><input type="submit" value="Go" /></td>
</tr>
</form>
2
Contributors
1
Reply
7
Views
4 Years
Discussion Span
Last Post by pritaeas
0

The error means your query failed. I suggest you add error checking to find out why:

$results = mysql_query($query) or die(mysql_error() . '<br/>' . $query);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.