Monday 23 May 2016

html - PHP While Loop Help- "Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result......"

Beware, I am a coding n00b and just got a basic PHP assignment. I keep getting this error message when I try to open this up



Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home/jpl8ce/public_html/php_grocery1.php on line 20


Here is my .php and .html files that go with what I'm doing. Basically, its a grocery database where I'm trying to print the store hours, address, and name of the store that has the item that the user inputs in the form.





Grocery Results!




$connect = mysqli_connect("localhost","jpl8ce","jpl8ce@siedb","grocery");
$item_name = $_post["input1"];

$query_String = " SELECT Stores.Name, Price, Address, Open_Time, Close_Time
FROM (Stores JOIN Carry ON Stores.Store_ID = Carry.Store_ID) JOIN Items ON Carry.Product_ID = Items.Product_ID
WHERE Items.name = $item_name

ORDER BY Close_Time DESC";


$result = mysqli_query($connect, $query_String);

while ($row = mysqli_fetch_assoc($result))
{

echo '

'.$row["Stores.Name"].', '.'

';
//echo '$' number_format($row["Price"],2).', ';

echo '

'.$row["Address"] .', '.'

';
echo '

'.$row["Open_Time"] .', '.'

';
echo '

'.$row["Close_Time"].'

';
}

mysqli_close($connect);
?>







Here is my HTML code





Grocery Database Search


Grocery Database Search!




Use this Search Engine to input a name of an item.
After clicking the Search button, the price of the item, as well as the address and hours of the store
the item is located at will be displayed.




Item:









Thanks again guys!

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...