Ten days to learn php-the sixth day _ PHP Tutorial

Source: Internet
Author: User
The sixth day of learning php in ten days. Objective: to learn how to add or delete the modified data mysql_query ($ exec). you can execute all the operations with this statement. The difference is that the SQL statement $ exec is added: $ execinsertinto. objective: learn to add, delete, and modify data

Mysql_query ($ exec );
This statement can execute all the operations. The difference is that the SQL statement $ exec

Add: $ exec = "insert into tablename (item1, item2) values ('". $ _ POST ['item1']. "',". $ _ POST ['item1']. ")";

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

Modify: $ exec = "update tablename set item1 = '". $ _ POST ['item1']. "'Where ...";

Let's talk about the transfer of form and php variables. if
If the form is submitted in POST mode, you can use $ _ POST ['item1'] to obtain the variable value for processing the Form File. Similarly, $ _ GET ['item1'] is submitted in GET mode.

Is it easy? But usually $ exec will have a problem, because your SQL statement may be very long, you will miss the. connector, or 'to enclose the character field.
Note mysql_query ($ exec); the statement uses echo $ exec; instead of $ exec to output $ exec to check whether the statement is correct. If you do not notice any error in $ exec, you can copy the SQL statement to phpmyadmin to check its error information. Note that we should not use sensitive strings as field names. otherwise, problems may occur, such as date. Variable naming: Field naming follows a certain rule. sometimes it is good for you. beginners cannot ignore its importance.

Let's talk about it today. you can go DOWN a reference manual for SQL statements and study it again. Continue to talk about the SESSION tomorrow.


Mysql_query ($ exec); you can execute all the operations with this statement. The difference is that the SQL statement $ exec is added: $ exec = "insert...

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.