I am trying to execute my PHP code, which calls two MySQL queries via mysqli, and get the error \"Commands out of sync; you can\'t run this command now\".
Here is th
Another cause: store_result() cannot be called twice.
For instance, in the following code, Error 5 is printed.
stmt_init();
if ($stmt->error) printf("Error 1 : %s\n", $stmt->error);
$stmt->prepare("select 1");
if ($stmt->error) printf("Error 2 : %s\n", $stmt->error);
$stmt->execute();
if ($stmt->error) printf("Error 3 : %s\n", $stmt->error);
$stmt->store_result();
if ($stmt->error) printf("Error 4 : %s\n", $stmt->error);
$stmt->store_result();
if ($stmt->error) printf("Error 5 : %s\n", $stmt->error);
(This may not be relevant to the original sample code, but it can be relevant to people seeking answers to this error.)