title: mysqli prepare() is returning a boolean true instead of a statement object
body: <p>I've seen this issue all over the internet but none of the solutions for others have fixed my errors.  I have the following PHP code:</p>
  
  <pre><code>  $err = false;
    $mysqli = getMysqlConnection();
    if ($stmt = $mysqli-&gt;prepare("INSERT INTO users (username, email, regtime, emailverified, type) values (?,?,?,?,?);"))
    {
        date_default_timezone_set("America/New_York");
        $dateStr = date("m-d-Y h:i:s");
        $emailverified = 0;
        $type = 0;
  
        $stmt-&gt;bind_param('sssii', $username, $email, $dateStr, $emailverified, $type);
        $rc = $stmt-&gt;execute();
        $err = $rc ? $err : true;
  
        $userId = $stmt-&gt;insert_id;    
  
        if ($stmt = $mysqli-&gt;prepare("INSERT INTO usercreds (user_id, username, hash) VALUES (?,?,?);") &amp;&amp; $err === false)
        {
            //
            //right here, for some reason, $stmt is true (boolean), not an object
            //
  
            $stmt-&gt;bind_param('iss', $userId, $username, $hash);
            $rc = $stmt-&gt;execute();
            $err = $rc ? $err : true;
        }
        else {
          $err = true;
        }
    }
  </code></pre>
  
  <p>The first query runs without problems, but the second query breaks on the call to bind_params.  I get the error </p>
  
  <blockquote>
    <p>Fatal error: Uncaught Error: Call to a member function bind_param() on boolean</p>
  </blockquote>
  
  <p>This means (and I have confirmed) that the second time I do <code>$stmt = $mysqli-&gt;prepare()</code>, it's returning a boolean rather than an object.  Furthermore, it's returning true, which I find very strange.</p>
  
  <p>I have quadruple checked my query, and it is perfectly fine and valid.  Yet for some reason the second time I try to prepare a statement he prepare method returns a boolean instead of a statement object.</p>
  
  <p>Another note, echoing out $mysqli->error after the second prepare() outputs nothing.</p>
  
  <p>How do I resolve this issue?</p>
  
  <hr>
  
  <p><strong>Afterthought:</strong></p>
  
  <p>Part of me feels like this is because I'm using the same mysqli object twice in a row? or maybe because I'm using the same statement object twice in a row?  Is there some sort of "shutting down" or "resetting" of one of these objects that needs to take place in order to execute a second query?</p>
  
  <p><strong>Another edit:</strong></p>
  
  <p>Additional proof that my second query is valid.  I copied and pasted it and replaced the ?'s with values, executed it in mysql workbench, and it ran perfectly fine.</p>
  
  <pre><code>INSERT INTO usercreds (user_id, username, hash) VALUES (1234567890,'testusr','hashhashhash');
  </code></pre>