Database Service
'; Echo "script" alert ('? Modified successfully '); window. location. href = 'index. php' script "; // modified successfully} else {echo'
'; Echo "script" alert ('? Modification failed '); window. location. href = 'guanli. php' script "; // modification failed}?>
This is the webpage code
The problem is that, even if my original password is incorrect, it is successfully changed to the index. php page, but the database does not change the original password correctly.
Reply to discussion (solution)
If ($ insert) {// determines whether execution is performed
This judgment is incorrect.
You just checked whether the update command is correct and did not check whether the modification was successful.
If mysql_affected_rows () is greater than 0, the modification is successful.
I have not read the manual carefully.
Http://www.w3school.com.cn/php/func_mysql_query.asp
Return value
Mysql_query () only returns a resource identifier for SELECT, SHOW, EXPLAIN or DESCRIBE statements. if the query execution is incorrect, FALSE is returned.
For other types of SQL statements, if mysql_query () is executed successfully, TRUE is returned. If an error occurs, FALSE is returned.
If the return value is not FALSE, the query is legal and can be executed by the server. This does not indicate any affected or returned number of rows. It is very likely that a query is successfully executed but does not affect or no rows are returned.
Check whether the number of rows is affected. use the mysql_affected_rows () function to check the number of rows.