Mysqlupdate is the method for php + MySQL to determine whether the update statement is successfully executed. Php + MySQL determines whether the update statement is successfully executed. the mysqlupdateupdate statement is a common operation in PHP + MySQL, determining whether the update statement is successfully executed is a very important method to judge whether the update statement is successfully executed in php + MySQL. mysqlupdate
The update statement is a common operation in PHP + MySQL. it is very important to judge whether the update statement is successfully executed. This article uses examples to demonstrate how php + MySQL can determine whether the update statement is successfully executed. Share it with you for your reference. The specific method is as follows:
Code 1:
$ Rs = MySQL_query ($ SQL); if (mysql_affected_rows () echo "SQL execution successful"; elseecho "SQL execution failed ";
Code 2:
<? Php/* connect to the database */mysql_pconnect ("localhost", "mysql_user", "mysql_passWord") or die ("cocould not connect ". mysql_error (); mysql_select_db ("mydb");/* Update record */mysql_query ("UPDATE mytable SET used = 1 WHERE id <10"); printf ("Updated records: % d \ n ", mysql_affected_rows (); mysql_query (" COMMIT ");?>
To observe the update execution, mysql_affected_rows () is required.
I believe this article has some reference value for everyone's PHP + MySQL program design.
Php checks whether mysql statements are successfully executed
If (false! = Mysql_query ($ SQL) {echo 'success! ';}
This judgment is sufficient! If the error occurs, you may have written an error in the previous code. please post it and see it! If you say "insert" returns false, I guess you have already executed mysql_query and then used it for judgment?
In php mysql, how does one determine that update has been successfully executed?
.......... Connect to the database .........
$ SQL = "update tb_user set name = 'sun' where id = 1 ";
$ Flag = mysql_query ($ SQL );
If ($ flag)
{
Echo 1;
}
Else
{
Echo "update error ";
}
References: du Niang
The explain update statement is a common operation in PHP + MySQL. it is very important to judge whether the update statement is successfully executed...