Jump to content

php array error in mysql query


kalster
Go to solution Solved by kalster,

Recommended Posts

when i run the below code i get an error...

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in...

but when i take out the h>0 then there is no errors in the code. in table users, i need all columns in the array. How to get h>0 working?

$query = "SELECT * FROM users WHERE h>0 ORDER BY id";
$result = mysqli_query($link, $query);

$data = array();
while($row1 = mysqli_fetch_array($result))
{
	$data[] = $row1;
} 

print_r($data);
Edited by kalster
Link to comment
Share on other sites

 also, here is the function that gives the error.

function getAllParents($id,$ibp){ //full path

foreach($ibp as $parentID=>$nodes){ 

    foreach($nodes as $node){

        if($node['id']==$id){

             if($node['parentId']!=0){

                $a=getAllParents($node['parentId'],$ibp);
                array_push($a,$node['parentId']);
                return $a;

              }else{
                    return array();
                  }

             }
    }
}
}
Link to comment
Share on other sites

 

 

i made a mistake about the error message.

Huh? How can you make a mistake? The two errors have two completely different meanings

 

 

 

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in...

This type of error usually indicates the query has failed. To find out why the query failed you need to use mysql_error

 

 

 

Warning: array_push() expects parameter 1 to be array, null given in

This means the variable you have given it as the first parameter is not an array.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.