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.
http://www.bkjia.com/PHPjc/328154.htmlwww.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...