From the manual, I know that the mysql_affected_rows function will return an abnormal value when the data before and after UPDATE are the same.
There is a convenient solution below. From the official munual, I saw the message from bdobrica at gmail dot com:
As a solution to the problem pointed in the post reffering to mysql_affected_rows() returning 0 when you are making an update query and the fields are not modified although the query is valid, i'm posting the following function. It is very simple and based on a previous post.
Copy code The code is as follows:
function mysql_modified_rows () {
$info_str = mysql_info( );
$a_rows = mysql_affected_rows();
ereg("Rows matched: ([0-9]*)", $info_str, $r_matched);
return ($a_rows < 1)? ($r_matched[1]?$r_matched[1]:0):$a_rows;
}
PS: After struggling with this small problem for a long time, I feel that php is really unclear.
http://www.bkjia.com/PHPjc/326696.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326696.htmlTechArticleI know from the manual that the mysql_affected_rows function will return an abnormal value when the data before and after UPDATE are the same. Here is a convenient method Solution, see bdobrica at gmail d from the official munual...