How PHP monitors data is successfully plugged into the MySQL database _php tips

Source: Internet
Author: User
Tags php code

Objective

This article is mainly about the PHP code in the monitoring data successfully inserted into the MySQL database, you can use these two ways. The following words do not say much, to see the detailed solution.

Solving method

The first is to judge by the mysql_query () function:

if (mysql_query (' insert INTO ... '))//returns True after the insert succeeds, the failure returns false
 echo "Success";
Else 
 echo "failed";

The second is to use the Mysql_affected_rows () function to return whether the value is greater than the 0来 judgment:

mysql_query ($sql 1); $flag 1 = mysql_affected_rows ();
mysql_query ($sql 2); $flag 2 = Mysql_affected_rows ();
mysql_query ($sql 3); $flag 3 = Mysql_affected_rows ();
if ($flag 1>0 && $flag 2>0 && $flag 3>0) {
 echo ' Insert succeeded ';

} else{
 echo ' Insert failed ';
}

Summarize

The above is the entire content of this article, I hope the content of this article for everyone to learn love or work can bring some help, if you have questions you can message exchange.

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.