Basic php and mysql tutorial (1/9)

Source: Internet
Author: User
Tags getting started with php mysql tutorial php and mysql php database

Basic php and mysql tutorials this chapter describes how to use PHP to operate MySQL databases, including connecting to the database, closing the database connection example, executing SQL statements to obtain the query result set, and obtaining the SQL statement execution error information, obtain all records in the result set, display data by PAGE, insert data into the database, submit the HTML page of user information, display the PHP program of data information, and add the PHP program that deletes the link, deleting database data is a complete basic tutorial for getting started with php mysql.

Php and mysql basic tutorials
This chapter describes how to use php to operate a mysql database, including connecting to a database, closing the database connection example, executing SQL statements to obtain the query result set, and obtaining information about SQL statement execution errors, obtain all records in the result set, display data by PAGE, insert data into the database, submit the html page of user information, display the php program of data information, and add the php program that deletes the link, deleting database data is a complete basic tutorial for getting started with php mysql.

1. php database connection example.
2. php closes the database connection.
3. Execute SQL statements in php.
4. php obtains information about SQL statement execution errors.
5. php gets the query result set.
6. php Retrieves all records in the result set.
7. php uses a php program to display table data.
8. php displays data by page.
9. html page for submitting user information.
10. Insert php data into the database.
11. php program for displaying data in php.
12. add and delete the link in php.
13. php deletes database data.

*/
// 1.php database connection example.

$ Host = 'localhost ';
$ User_name = 'root ';
$ Password = 'admin ';

$ Conn = mysql_connect ($ host, $ user_name, $ password );
If (! $ Conn)
{
Die ('database Connection Failed: <br/> '. mysql_error ());
}
Echo 'database connection successful! ';

 

// 2.php closes the database connection.

$ Host = 'localhost ';
$ User_name = 'root ';
$ Password = 'admin ';

$ Conn = mysql_connect ($ host, $ user_name, $ password );
If (! $ Conn)
{
Die ('database Connection Failed: '. mysql_error ());
}
Echo 'database connection successful! ';

If (mysql_close ($ conn ))
{
Echo '<br/>... <br/> ';
Echo 'the connection to the database has been closed successfully ';
}

1 2 3 4 5 6 7 8 9

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.