kalster Posted October 28, 2014 Share Posted October 28, 2014 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 More sharing options...
kalster Posted October 28, 2014 Author Share Posted October 28, 2014 i made a mistake about the error message. the error message is... Warning: array_push() expects parameter 1 to be array, null given in Link to comment https://forums.phpfreaks.com/topic/292108-php-array-error-in-mysql-query/#findComment-1494987 Share on other sites More sharing options...
kalster Posted October 28, 2014 Author Share Posted October 28, 2014 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 https://forums.phpfreaks.com/topic/292108-php-array-error-in-mysql-query/#findComment-1494990 Share on other sites More sharing options...
Ch0cu3r Posted October 28, 2014 Share Posted October 28, 2014 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 https://forums.phpfreaks.com/topic/292108-php-array-error-in-mysql-query/#findComment-1494999 Share on other sites More sharing options...
kalster Posted October 28, 2014 Author Share Posted October 28, 2014 I was trying to fix the error and had another error. i just mixed the error messages. i fixed the error by giving a value of 1 instead of 0 in another function. Link to comment https://forums.phpfreaks.com/topic/292108-php-array-error-in-mysql-query/#findComment-1495045 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.