PHP - Weird behaviour of mysqli -


im running strange problem of sudden:

i have php script executing query:

$query = "select shoporderid, paymentid shop_order done = 0 , paymentlockdate not null , unix_timestamp(orderdate + 7200 < unix_timestamp(now())"; 

the query fine, when print pma executes fine , gives me 12 results processed.

now execute query , gather result:

$handle = new mysqli(     $config->getsqlhost(),     $config->getsqluser(),     $config->getsqlpw(),     $config->getsqldbname(),     $config->getsqlport() );  $result = $handle->query($query); 

now add thing, if try loop result:

if(is_object($result) == true) { //is_object returns true!     while($row = $result->fetch_assoc()) { //but error o.o      } } 

i get:

fatal error: call member function fetch_assoc() on non-object in /var/www/(and on...)/myscript.php on line 34  

now weirdo thing is, if tests on object $result says:

var_dump(is_object($result)); //bool(true)   var_dump(get_class($result)); //string(13) "mysqli_result"  var_dump($handle->error()); //string(0) ""  var_dump($handle->errno()); //int(0)  var_dump($result); //object(mysqli_result)#4 (5) { ["current_field"]=> int(0) ["field_count"]=> int(2) ["lengths"]=> null ["num_rows"]=> int(13) ["type"]=> int(0) }  

there absolutely valid result set 13 rows , 2 fields according query. fine , still when try loop "non-object". happening here? encountered problem?

would appreciate hints.

and no: result not overwritten anywhere, did var_dumps on object 1 line before call this: while($row = $result->fetch_assoc()) { ...


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -