Forum Moderators: coopster
so I try using the mysql_affected_rows(),
however regardless of updates within an existing row
it keeps showing "no updates" (I know updates were passed)
I simplyfied the echo wordings but the skeleton script is the same
$num = mysql_affected_rows($sql, $conn);
if ($num == 0) {
echo "<p>No update yet!</p>";
} else {
echo $num;
echo "<p>Updated!</p>";
}
Thank you
mysql_affected_rows()
When you use an argument, it needs to be the 'link identifier' handler. This is just a single variable, not two like you've got - just a modest suggestion, I haven't used this function so I can't give you detailed info. Also, have you tried doing this with error_reporting(E_ALL)? It might give you some info if there's something wrong.
I forgot about an "updated field"
so even if no updates are performed
it will always show "updated" for when submited even without modif the updated time will change
so I think that I should do a "isset" against each other updatable fields
but it is a long task (about 60 fields)
any way to shorten my quest?
thanks
When using UPDATE, MySQL will not update columns where the new value is the same as the old value. This creates the possibility that mysql_affected_rows() may not actually equal the number of rows matched, only the number of rows that were literally affected by the query.