How to learn the sixth day of PHP in 10 days

Source: Internet
Author: User

Learning Purpose: Learn to add delete modify data

mysql_query ($exec);

Single This statement can perform all the operations, the difference is $exec this SQL statement

Add: $exec = INSERT INTO tablename (ITEM1,ITEM2) VALUES ('. $_post[' item1 ']. "', ' $_post[' item1 ']."

Delete: $exec = "Delete from tablename where ...";

Modified: $exec = "UPDATE tablename set item1= '". $_post[' item1 '. "' Where ... ';

Speaking of which, we'll talk about forms and PHP variable delivery if one of the forms
The form is submitted by POST, then processing the form file can get the value of the variable with $_post[' item1 ', which is also the $_get[' item1 ' submitted.

Is it simple? But usually $exec can be problematic because your SQL statements may be very long, and you'll miss out. Connectors, or ' to surround character fields.

We can annotate mysql_query ($exec); statements use echo $exec instead to output $exec to check for correctness. If you are not aware of any $exec errors, you can copy the SQL statement to phpMyAdmin and see its error message. It is also important to note that we do not use sensitive strings as field names, otherwise there are likely to be problems, such as date or something. The name of the variable, the name of the field follow a little rule sometimes it's a good thing for yourself, and beginners can't ignore its importance.

Today is the point, tomorrow will continue the session.



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.