Database Service-php Tutorial

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.