title: mysql_affected_rows() returns 0 for UPDATE statement even when an update actually happens
body: <p>I am trying to get the number of rows affected in a simple mysql update query.  However, when I run this code below, PHP's mysql_affected_rows() always equals 0.  No matter if foo=1 already (in which case the function <strong>should correctly</strong> return 0, since no rows were changed), or if foo currently equals some other integer (in which case the function should return 1).</p>
  
  <pre><code>$updateQuery = "UPDATE myTable SET foo=1 WHERE bar=2";
  mysql_query($updateQuery);
  if (mysql_affected_rows() &gt; 0) {
      echo "affected!";
  }
  else {
      echo "not affected"; // always prints not affected
  }
  </code></pre>
  
  <p>The UPDATE statement itself works.  The INT gets changed in my database.  I have also double-checked that the database connection isn't being closed beforehand or anything funky.  Keep in mind, mysql_affected_rows doesn't necessarily require you to pass a connection link identifier, though I've tried that too.</p>
  
  <p>Details on the function: <a href="http://php.net/manual/en/function.mysql-affected-rows.php" rel="noreferrer">mysql_affected_rows</a></p>
  
  <p>Any ideas?</p>