Jump to content
Larry Ullman's Book Forums

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.

Link to comment
Share on other sites

  • 5 months later...

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. 
Link to comment
Share on other sites

  • 4 years later...

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

Link to comment
Share on other sites

  • 4 months later...

I am also getting an error with my code while trying to display something on the page

The error is

WARNING: mysqli_num_rows() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\ECE\ramonsys\include\database.php on line 98

 

the code is 

public function num_rows() {

    $cur = $this->executeQuery();

    return mysqli_num_rows($cur));

}

 

what can I do to fix the problem? Thank you!

Link to comment
Share on other sites

  • 4 weeks later...

I am having the same problem however if i run my sql code on the DB it works.

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php
        
        // put your code here
        $user_name= "11";
       
        $conn = mysqli_connect('localhost', "root", "", "Invoices");
      
       if (!$conn){
           
           
           echo "Cannot find database";
       }
 else {
           $mysql1 = "SELECT `Invoice_ID`, `Served_by`, `Date_served`, `Time_served`, `Cost` FROM `payment` WHERE `Invoice_ID` like '.$user_name''";
           $result = mysqli_query($conn, $mysql1);
           mysqli_store_result($conn);
           $numrows = mysqli_num_rows($result);
       }
             if ($numrows > 0) {
           
             echo "Login succesful";
           
       }
             else {
                   echo "User not found or invalid credentials";
       }
       
       
       
       ?>
    </body>
</html>

Link to comment
Share on other sites

  • 3 weeks later...
On 3/20/2019 at 9:01 PM, Larry said:

That means your SELECT query isn't working. You'll need to run it separately on the server to see what the results are (i.e., what the error is).

<?php
//reading the database
$conn=mysqli_connect ("localhost", "root", "");
      if (!$conn) {
          echo "server connction error";
      }
      $db_conn = mysqli_select_db($conn, "test2");
      $sql = "select id, name, email, passwd from f_user";
      $query = mysqli_query($conn, $sql);
      
?>
<table>
      <tr>
            <td><strong>username</strong></td>
            <td><strong>email</strong></td>
            <td><strong>Passwd</strong></td>
            <td><strong>Action</strong></td>
      </tr>
      <?php
if (mysqli_num_rows($query)>=1){
      while ($row=mysqli_fetch_assoc($query)){

      ?>
      <tr>
            <td><?php echo $row['name'];?></td>
            <td><?php echo $row['email'];?></td>
            <td><?php echo $row['passwd'];?></td>
            <td><a href="edit.php?id=<?php echo $row['id'];?>"> Edit</a> I <a href
            ="delete.php?id=<?php echo $row['id']; ?>">Delete</a></td>
      </tr>
      <?php
}}
?>
</table>

Link to comment
Share on other sites

  • 7 months later...

It's not a matter of secrets. Forums like these or Stack Overflow are here expressly to share information and to help others. Honestly, the absolutely best thing to do would be to use mysqli_error() b/c then MySQL will tell you what the problem is, whereas we're just guessing. But without that knowledge my best guess would be that the PHP user for the script doesn't have execute permissions to run the stored procedure. Or you have the database wrong. In either case, mysqli_error() should tell you the actual cause.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...