Let me begin by apologizing if there was a duplicate of this error. I searched and found nothing explicitly pertaining to my situation, though the same error message was presented. I'm new to PHP, and I'm attempting to use an HTML Search form in order to retrieve a record in my table.My code looks like this`
<form action="" method="post">
Search: <input type="text" name="term" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'pass';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ){
die('Could not connect: ' . mysql_error());
}
if (!empty($_REQUEST['term'])) {
$term = mysql_real_escape_string($_REQUEST['term']);
$sql = "SELECT * FROM shoes WHERE name LIKE '%".$term."%'";
$r_query = mysql_query($sql);
while($row = mysql_fetch_array($r_query)){
echo 'Shoe Name: ' .$row['name'];
echo '<br /> SKU: ' .$row['sku'];
echo '<br /> Size: ' .$row['size'];
echo '<br /> Quantity: ' .$row['quantity'];
}
}
mysql_close($conn);
?>
` And i get this error message: mysql_fetch_array() expects parameter 1 to be resource, boolean given
I'd greatly appreciate any help on the matter. I'm stumped.