An exception occurred when php updated mysql to obtain the affected number of rows. I learned from manual that the mysql_affected_rows function will return abnormal values when the data before and after UPDATE is the same. The following is a convenient solution, from the official munual, we can see that bdobricaatgmaild knows from manual that the mysql_affected_rows function returns abnormal values when the data before and after UPDATE is the same,
The following is a convenient solution. the bdobrica at gmail dot com message is displayed on the official munual:
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.
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: I 've been tossing for a long time because of this small problem. I feel that php is too unclear.
Finally, there is a convenient solution below. from the official munual, we can see bdobrica at gmail d...