title: $stmt->execute() : How to know if db insert was successful?
body: <p>With the following piece of code, how do i know that anything was inserted in to the db?</p>
  
  <pre><code>if ($stmt = $connection-&gt;prepare("insert into table (blah) values (?)")) {
  $stmt-&gt;bind_param("s", $blah);  
  $stmt-&gt;execute();           
  $stmt-&gt;close();                                 
  }
  </code></pre>
  
  <p>I had thought adding the following line would have worked but apparently not.</p>
  
  <pre><code>if($stmt-&gt;affected_rows==-1){$updateAdded="N"; echo "failed";}  
  </code></pre>
  
  <p>And then use the $updatedAdded="N" to then skip other pieces of code further down the page that are dependent on the above insert being successful.</p>
  
  <p>Any ideas?</p>