title: mySQLi insert error - Call to a member function bind_param
body: <p>I got this very simple mysqli query that fails and returns this message:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in M:\xampp\htdocs\insert\form-handler.php:17 Stack trace: #0 {main} thrown in M:\xampp\htdocs\insert\form-handler.php on line 17</p>
  </blockquote>
  
  <p>HTML:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;Document&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form action="form-handler.php" method="POST"&gt;
          &lt;input type="text" name="firstname"&gt;
          &lt;input type="text" name="lastname"&gt;
          &lt;input type="submit"&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>$firstname = $_POST['firstname'];
  $lastname = $_POST['lastname'];
  
  $mysqli = new mysqli('localhost', 'root', '', 'firstlast');
  
  if (mysqli_connect_errno()) {
      printf("Connect failed: %s\n", mysqli_connect_error());
      exit();
  }
  
  $stmt = $mysqli-&gt;prepare('INSERT INTO users (id, firstname, lastname) VALUES ("", ?, ?');
  
  $stmt-&gt;bind_param('ss', $firstname, $lastname);
  
  $stmt-&gt;execute();
  
  $stmt-&gt;close();
  </code></pre>
  
  <p>Is there anything that I have missed? Thanks.</p>