Link MySQL with PHP

Source: Internet
Author: User

First, query MySQL database using PHP:

1. The steps to access MySQL via PHP are:

    1. Connect to MySQL
    2. Select the Operational database
    3. Create a field for a query
    4. The statement that executes the query
    5. Retrieve the results and display them on the Web page
    6. Disconnecting from MySQL

We will do these operations in turn, it is important to first create the login details in a secure manner so that others do not have easy access to your database.

2. Create a login file:

Many web sites created in PHP contain several program files that require access to MySQL and require login and password information, so create a separate file to store the information and place it wherever it is needed.

// login.php $db _hostname = ' localhost '; $db _database = ' my_database '; $db _username = ' username '; $db _password = ' password ';? >

3. Connect to the MySQL database:

Now that the login.php file has been created and saved, it can be included in any PHP file that requires access to the data through the require_once statement.

Link MySQL with PHP

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.