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