Test example for PHP to determine if the database is connected successfully
If there is an incorrect database configuration, see the PHP and MySQL configuration tutorial:
How to configure the Php-apache-mysql environment under the Win7 system http://www.cnblogs.com/myall/p/4744837.html
Phperror_reporting(~E_all); $host=$_post[' Host ']; $user=$_post[' User ']; $pwd=$_post[' pwd ']; if(isset($_post[' Host ']) &&isset($_post[' User ']) &&isset($_post[' pwd '])){ if(strlen($host) <1 orstrlen($user) <1 orstrlen($pwd) <1){ Echo"Please complete the relevant database link information. "; Exit(0); } $conn=mysql_connect($host,$user,$pwd) or die("error-Database connection failed! "); if($conn){ Echo"Ok-database connection was successful! "; } }?>
The above describes the PHP to determine whether the database connection success test example, including the content, I hope the PHP tutorial interested in a friend helpful.