Home  >  Article  >  Backend Development  >  A simple example of connecting LAN MYSQL database with PHP_PHP tutorial

A simple example of connecting LAN MYSQL database with PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 14:59:131133browse

Copy code The code is as follows:

$conn=mysql_connect('192.168.0.220','root','123' );
if(!$conn) echo "Failed!";
else echo "Success!";

// SQL statement to extract information from the 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 certain host in the LAN. For mysql connection in the LAN, please refer to my excerpt.

The sixth line $user_name is the parameter passed by the front desk, forming a conditional query. Double quotation marks are used here for variable conversion.

From jsp to php, no matter which one, the steps related to database connection are roughly:

"Host, username, password" gets the connection, "database, sql, connection" gets the result, and finally the processing and display of the result. Of course, the database connection is done for us by the extension library, and all we can do is process the results.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328154.htmlTechArticleCopy the code as follows: $conn=mysql_connect('192.168.0.220','root','123') ; if(!$conn) echo "Failure!"; else echo "Success!"; // SQL statement to extract information from the table $sql="SELECT * FR...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn