PHP connection MySQL is the first step in the database operation, in PHP, you can use the built-in PHP function mysql_connect () to implement, the function format is mysql_connect ("MySQL hostname", "MySQL User name", "MySQL password" ), the following test code can test for a successful connection to MySQL:
<?php$conn = mysql_connect ("localhost", "root", "pass") or Die ("Connect err:". Mysql_error ()); echo "MySQL database succeeded! ";? >
In the test code above: Assuming that the MySQL host name is native localhost, the username and password are root, subject to your actual hostname and user name password, the Die function is intended to terminate the program when the MySQL connection fails and to output the cause of the error.
This article is from the "Operation and maintenance House (Q Group: 1991706)" blog, please be sure to keep this source http://304076020.blog.51cto.com/7503470/1571723
PHP link MySQL code test