title: MySql error "could not update record" error number 0 - when no change to record
body: <p>When I update a field in a MySQL database using MySQLi, I check the number of affected rows to see if the query was successful. If the value of the field does not actually change then I get an error message. For example, if you try to change the value of the field "chips" to "utz" when the value is already "utz" I receive the following error:</p>
  
  <pre><code>Could not update record: (0)
  </code></pre>
  
  <p>This is because the number of affected rows is 0, since why change something that is already the correct value. Is there a "good practice" way of avoiding this error?</p>
  
  <p>I have seen people try to get around this by updating a "current_time_stamp" value in their database so that a field will always be updated. But that doesn't seem like a good way to handle this instance. </p>
  
  <p>On my website, I attempt to check if the value has changed. I use javascript's onChange to call a function, I set a variable to reflect a change has been made that I later check to see if the database should be updated. But this does not always result in an actual change. Sometimes the function will get called even if no change has been made. Any suggestions?</p>
  
  <p>Here is the code I use when checking for the number of affected rows:</p>
  
  <pre><code>    if ($databaseObject-&gt;affected_rows)
      {
          //echo "Success!&lt;br&gt;";
      }
      else 
      {
          echo "Could not update record: (" . $databaseObject-&gt;errno . ") " . $databaseObject-&gt;error . "&lt;br&gt;";
      }
  </code></pre>