mysql - PHP fetch_array() on a non-object -


i have php code.

if (isset($user)){             if (is_object($user)) {                 if (!$result_paycon = $mysqli->query("call check_convention(" . $user->id . "," . $row_convention["idconvention"] . ")")){                     printf("database error");                     exit;                  }                  if (!$result_block = $mysqli->query("select * view_roomblock idconvention = " . $row_convention["idconvention"])){                     var_dump($result_block);                     printf("database error");                     exit;                 }             }         } 

no matter it, var dump of $result block bool(false). , when need use fetch_array on it, tells me $result_block non-object. however, changing first query procedure call regular select seems fix issue, removing entirely code.

i echoed sql query both calls, , both return if plug them sql directly.

is there i'm not doing?

edit 1: still having no luck. however, if invert code this:

if (!$result_block = $mysqli->query("select * view_roomblock idconvention = " . $row_convention["idconvention"])){                     printf("database error");                     exit;                 }                  if (!$result_paycon = $mysqli->query("call check_convention(" . $user->id . "," . $row_convention["idconvention"] . ")")){                     printf("database error");                     exit;                  }                  var_dump($result_block);                 echo "<br />";                 var_dump($result_paycon); 

i following var dumps:

object(mysqli_result)#4 (5) { ["current_field"]=> int(0) ["field_count"]=> int(10) ["lengths"]=> null ["num_rows"]=> int(2) ["type"]=> int(0) } object(mysqli_result)#5 (5) { ["current_field"]=> int(0) ["field_count"]=> int(2) ["lengths"]=> null ["num_rows"]=> int(1) ["type"]=> int(0) }  

but former code, 1 of them fails, still have no idea why.

edit 2: printed value of error property of mysqli object in former code. following:

commands out of sync; can't run command now

figured out problem. need run next_result() method prepare $mysqli object query/result set. implied earlier in comments in mysql documentation, free_result should work. reason, doesn't me.

so works:

if (isset($user)){             if (is_object($user)) {                 if (!$result_paycon = $mysqli->query("call check_convention(" . $user->id . "," . $row_convention["idconvention"] . ")")){                     printf("database error");                     exit;                  }                 $result_paycon->close();                 $mysqli->next_result();                  if (!$result_block = $mysqli->query("select * view_roomblock idconvention = " . $row_convention["idconvention"])){                     var_dump($result_block);                     printf("database error");                     exit;                 }             }         } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -