Knowledgebase

How to check the PHP MYSQL connection: Test file?

How to check the PHP MYSQL connection: Test file?

If you wish to check the MYSQL test file connection, then copy the below given code and paste it in the test.php file and execute it in your web browser. Through the results, you can check the connection of the file. 

In case you do not receive the output, you should approach your service provider. 

Code:


$link = mysql_connect ('localhost', '', '');

if (!$link) { 

die('Could not connect: ' . mysql_error() ); 



echo 'Connected successfully'; 

$db_selected = mysql_select_db('', $link); 

if (!$db_selected) { 

die ('Can\'t use foo : ' . mysql_error() ); 



mysql_close($link); 

?> 

* In the above code, you should replace the 'username, password and database' with your login details and database name. 
  • 0 Users Found This Useful
Was this answer helpful?