title: MySqli Commands out of sync; you can't run this command now
body: <p>I have converted my register script from mysql to mysqli. I worked fine as mysql however it now gives me the error </p>
  
  <pre><code>Commands out of sync; you can't run this command now
  </code></pre>
  
  <p>This is the function I use to register the user</p>
  
  <pre><code>function register_user($register_data) { 
  global $myConnection;
  array_walk($register_data, 'array_sanitize'); 
  //Make the array readable and seperate the fields from data 
  $fields = '`' . implode('`, `', array_keys($register_data)) . '`'; 
  $data = '\'' . implode('\', \'', $register_data) . '\''; 
  //Insert the data and email an activation email to the user 
  mysqli_query($myConnection, "INSERT INTO `members` ($fields) VALUES ($data)") or die(mysqli_error($myConnection)); 
  email($register_data['mem_email'], 'Activate your account', "Hello " . $register_data['mem_first_name'] . ",\n\nThank you for creating an account with H Fencing. Please use the link below to activate your account so we can confirm you identity:\n\nhttp://blah.blah.co.uk/activate.php?mem_email=" . $register_data['mem_email'] . "&amp;email_code=" . $register_data['email_code'] . "\n\n - David &amp; Jay "); 
  }
  </code></pre>
  
  <p>The email sends fine with the correct data from my array. However no data is inserted into the database and I get the error mentioned above. I have never come across this error before.</p>