title: PHP MySQLi Asynchronous Queries with
body: <p>I am trying to use asynchronous queries via PHP MySQLi.</p>
  
  <p>The following code has been simplified, the original is code is too verbose to list here because of class dependencies and all that. Also please assume the reference to the connection <code>mysqli_handle</code> has already been setup. </p>
  
  <pre><code>$query_1 = "SHOW TABLES FROM moxedo";
  $query_2 = "CREATE TABLE `moxedo`.`mox_config_n85ad3` (`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT , `group_id` INT(3) UNSIGNED NOT NULL , `is_enabled` INT(1) UNSIGNED NOT NULL , `tag` VARCHAR(255) NOT NULL , `name` VARCHAR(80) NOT NULL , `value` VARCHAR(255) NOT NULL , `description` TEXT NOT NULL , `init_params` TEXT NOT NULL , `datetime_added` DATETIME NOT NULL , `datetime_lastmodified` DATETIME NOT NULL , `timestamp_univ` BIGINT(14) NOT NULL , PRIMARY KEY ( `id` ) ) ENGINE = INNODB
  ";
  $query_3 = "ALTER TABLE `moxedo`.`mox_config_n85ad3` ADD UNIQUE `ix_u_tag_oq` ( `tag` )";
  $query_4 = "SHOW TABLES FROM moxedo";
  
  if (!$mysqli_stmt_obj = $mysqli_handle-&gt;query($query_1)) 
  {
     printf("Error: %s\n", $mysqli_handle-&gt;error);
  }
  
  if (!$mysqli_stmt_obj = $mysqli_handle-&gt;query($query_2, MYSQLI_ASYNC)) 
  {
     printf("Error: %s\n", $mysqli_handle-&gt;error);
  }
  
  if (!$mysqli_stmt_obj = $mysqli_handle-&gt;query($query_3, MYSQLI_ASYNC)) 
  {
     printf("Error: %s\n", $mysqli_handle-&gt;error);
  }
  
  if (!$mysqli_stmt_obj = $mysqli_handle-&gt;query($query_4)) 
  {
     printf("Error: %s\n", $mysqli_handle-&gt;error);
  }
  </code></pre>
  
  <p>The call to Query 1 goes through OK. The call to Query 2 also goes through OK.</p>
  
  <p>However, I'm getting "Commands out of sync; you can't run this command now" errors when I try to execute Query 3 and Query 4. From my research online I found some information on using <code>mysqli_free_result</code> but Query 2 and Query 3 return no resultset.</p>
  
  <p>What do I need to do to properly finalize the asynchronous call so that I can make multiple calls without getting this error?</p>