title: mysqli why does this happens?
body: <p>I have two subsequent mysqli statements, and the second returns:</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function bind_param() on a non-object in ...</p>
  </blockquote>
  
  <p>Why this happens? Does this means that I need to open two different connection?
  Is there any way to avoid this (I love keeping the SQL connection details in one file)?</p>
  
  <p>Here the code:</p>
  
  <pre><code>$db = new mysqli("localhost", "root", "", "database");
  
  $stmt = $db-&gt;prepare("UPDATE posts SET vote_".$_POST['vote']." = vote_".$_POST['vote']." + 1 WHERE id=?");
  $stmt-&gt;bind_param('s', $_POST['id_post']);
  $stmt-&gt;execute();
  $stmt-&gt;close();
  
  $stmt = $db-&gt;prepare("INSERT INTO votes (kind, users_id, posts_id) VALUES (?, ?, ?)");
  $stmt-&gt;bind_param('sss',$_POST['vote'],$_POST['id_user'],$_POST['id_post']);
  $stmt-&gt;execute();
  $stmt-&gt;close();
  </code></pre>