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. 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.Copy codeThe 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.