Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
Jane39

Mysqli_Num_Rows() Expects Parameter 1 To Be Mysqli_Result, Boolean Given Array

Recommended Posts

I'm running PHP files of example 2 from my computer and I got those following errors across pages.

 

An error occurred in script 'D:\XAMPP\htdocs\ex2\html\views\home.html' on line 14:
mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given
Array

 

An error occurred in script 'D:\XAMPP\htdocs\ex2\html\shop.php' on line 32:
mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given
Array

 

An error occurred in script 'D:\XAMPP\htdocs\ex2\html\sales.php' on line 20:
mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given
Array

 

An error occurred in script 'D:\XAMPP\htdocs\ex2\html\wishlist.php' on line 80:
mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given
Array

 

An error occurred in script 'D:\XAMPP\htdocs\ex2\html\cart.php' on line 81:
mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given
Array

 

Can someone please tell me how to fix it? Thanks.

Share this post


Link to post
Share on other sites

Awesome Hartley. I made the php files work finally. It's my fault when I didn't create stored procedures as guidance in Larry's book at first. You're always helpful Hartley. Thank you. :)

Share this post


Link to post
Share on other sites

I am also running into the same problem the  difference  however, is that am running mine on a live server. 

So my error is as follow:

 

An error occurred in script '/home/content/82/11778682/html/shop/views/home.html' on line 9:
mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given
 

This is what line 9 actually looks like:

 
// If records are returned, include the view:
if (mysqli_num_rows($r) > 0) {
 
echo '<dl class="special fright">
<dt><a href="/shop/sales/">Sale Items</a></dt>';
 
// Fetch each item:
   while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
    echo '<dd><a href="/shop/sales/#' . $row['sku'] . '" title="View This Product"><img alt="" src="/products/' . $row['image'] . '" /><span>' . $row['sale_price'] . '</span></a></dd>';
   }
 

 

echo '</dl>';
 
 
I would really appreciate it if you can help me resolve this issue. 

Share this post


Link to post
Share on other sites

That means your SELECT query isn't working. You'll need to run it separately on the server to see what the results are. 

Share this post


Link to post
Share on other sites

I am also getting an error in my code while searching something..

I am sending my code please check it once and then revert me back with the correct code.

<?php
$result = mysqli_query($con,"SELECT * FROM `packages` WHERE `Name`, `Cities`, `Destinations`, `Duration`");
$rows = mysqli_num_rows($result);
echo $rows;
?>

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\search\bar.php on line 29

this error is coming .. please resolve this error

Share this post


Link to post
Share on other sites

That means your SELECT query isn't working. You'll need to run it separately on the server to see what the results are. Hint: the problem is syntactical, from "WHERE" on. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×