PHP connection LAN MySQL database simple example _php tutorial

Source: Internet
Author: User
Copy CodeThe code is as follows:
$conn =mysql_connect (' 192.168.0.220 ', ' root ', ' 123 ');
if (! $conn) echo "Failed!";
else echo "Success!";

SQL statement that extracts information from a table
$sql = "SELECT * from user where username= ' $user _name '";
Execute SQL query
$result =mysql_db_query (' info ', $sql, $conn);
Get query Results
$row =mysql_fetch_row ($result);
Mysql_close ();

The first line of IP corresponds to a local area network host, about the LAN MySQL connection can refer to my excerpt.

Line Six $user_name is the foreground passed parameters, composed of conditional query, here is a double quote variable conversion.

From JSP to PHP, either way, the steps related to database connections are basically:

"Host, username, password" Get Connected, "database, SQL, connect" Get results, and finally the result of the processing display. Of course, the database connection is the extension library for us, and all we can do is just deal with the results.

http://www.bkjia.com/PHPjc/328154.html www.bkjia.com true http://www.bkjia.com/PHPjc/328154.html techarticle Copy the code as follows: $conn =mysql_connect (' 192.168.0.220 ', ' root ', ' 123 '), if (! $conn) echo "Failed!" and else echo "success!"; SQL statement that extracts information from a table $sql = "SELECT * FR ...

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