Simple example of connecting MYSQL database in the LAN using PHP

Source: Internet
Author: User
This article introduces a simple example of connecting PHP to the MYSQL database in the LAN. if you need it, refer to it. The code is as follows:
$ Conn = mysql_connect ('192. 168.0.220 ', 'root', '123 ');
If (! $ Conn) echo "failed! ";
Else echo "successful! ";

// SQL statement used to extract information from the table
$ SQL = "SELECT * FROM user where userName = '$ user_name '";
// Execute SQL query
$ Result = mysql_db_query ('info', $ SQL, $ conn );
// Obtain the query result
$ Row = mysql_fetch_row ($ result );
Mysql_close ();

The ip address of the first line corresponds to a host in the LAN. For more information about mysql connection in the LAN, see my excerpt.

Row 6 $ user_name is the parameter passed at the front end. it constitutes a condition query. the double quotation mark variable conversion is used here.

From jsp to php, the steps related to database connection are roughly as follows:

"Host, user name, password" to get the connection, "database, SQL, connection" to get the result, and finally the result is displayed. Of course, the database connection is done by the extended Database. All we can do is process the results.

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: 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.