title: mysqli - handling errors with transactions
body: <p>How to properly handle errors with transactions and prepared statements when using mysqli?</p>
  
  <p>Snippet:</p>
  
  <pre><code>&lt;?php
  $conn = require_once 'dbconn.php';
  $conn-&gt;autocommit(FALSE);
  
  $stmt_ins_option = $conn-&gt;prepare('INSERT INTO options(option_name) VALUES(?)');
  $option_name = 'foo';
  $stmt_ins_option-&gt;bind_param('s', $option_name);
  $stmt_ins_option-&gt;execute();
  $conn-&gt;commit();
  if($conn-&gt;errno) {
      $conn-&gt;rollback();
      echo $conn-&gt;error;
  }
  </code></pre>
  
  <p>It won't add it a second time because there's a UNIQUE constraint on that column.</p>
  
  <p>However the script won't report any error either.</p>
  
  <p>What am I missing?</p>