Jump to content

php array error in mysql query


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);
Link to comment
https://forums.phpfreaks.com/topic/292108-php-array-error-in-mysql-query/
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();
                  }

             }
    }
}
}

 

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.