title: Can I safely assume this INSERT succeeded?
body: <p>I'm using MySQL with strict mode turned on. I am inserting data supplied by user through an HTML form. I've already done all my validation and this is the final step.</p>
  
  <p><strong>Here is an excerpt from my PHP code:</strong></p>
  
  <pre><code>$sql = 'SET sql_mode = TRADITIONAL'; //last chance data validation
  $mysqli-&gt;query($sql) or output_error('Database Error: Failed to set SQL mode');
  
  $db_err_msg = 'Database Error: Failed to update profile summary';
  $sql = "INSERT INTO {$tables['text']} (lngProfileId, memProfileText) VALUES(?, ?)
      ON DUPLICATE KEY UPDATE memProfileText = VALUES(memProfileText)";
  $stmt = $mysqli-&gt;prepare($sql) or output_error($db_err_msg);
  $stmt-&gt;bind_param('is', $profile_id, $_POST['memProfileText'])
      or output_error($db_err_msg);
  $stmt-&gt;execute() or output_error($db_err_msg);
  $stmt-&gt;close();
  
  //if code reaches this point, can it assume insert/update succeeded?
  </code></pre>
  
  <p><strong>Note:</strong> <code>output_error</code> is my error handler for fatal errors. It doesn't return; it exits.</p>
  
  <p>Do I need to check for warnings? Or can I safely assume the insert/update succeeded? Is there some scenario that could cause a warning instead of an error even with strict mode turned on?</p>
  
  <p><strong>EDIT:</strong> I'm only concerned about things that should be considered <em>fatal</em> errors. If it was updated rather than inserted, that is of no concern to me. That's not an error.</p>
  
  <p>Also, <code>last_insert_id</code> and <code>affected_rows</code> are meaningless in this case. If the user didn't make any changes, affected_rows will be 0 and the value of last_insert_id will not be updated.</p>
  
  <p>My definition of <em>succeeded</em> in this case:</p>
  
  <ul>
  <li>it inserted the record or updated the record or did nothing if no changes were made</li>
  <li>it did not 'silently mangle my data' </li>
  </ul>
  
  <p>Many newbie programmers make the mistake of <em>assuming</em> that a query succeeded without ever checking the return value or warnings. Their code <em>works</em>... under normal conditions.</p>
  
  <p><em>My question is:</em> <strong>"Considering my code, with strict mode turned on, and the error checking I've done, is it safe to assume the query succeeded? Is that a correct or incorrect assumption? Should I also check for warnings or would that be redundant?"</strong></p>