Check MySQL database connection in PHP using script dynamically

How to test MySQL db server connectivity server is connected or not with php script.

Testing server database connectivity is very most important thing before starts uploading php dynamic website on server. Because if you website is not connected to MySQL db server then you do not able to see dynamic content which is coming from database on your website . So this file helps you to manage and check your whole website connectivity to its database. This simple script gives you to check any php database connectivity by simply changing your website host-name, database username, database password and database name which will provided by your hosting provider. So here is the complete step by step tutorial for Check MySQL database connection in PHP using script dynamically.

android-project-download-code-button

How to Check MySQL database connection in PHP using script dynamically.

Code for Check-MySQL-database-connection.php file.

 <?php

//Define your host here.
$host = "localhost";

//Define your database username here.
$username = "root";

//Define your database password here.
$password = "";

//Define your database name here.
$dbname = "test";

////Define your error message which you want to display if anything goes wrong .
$errorMessage = "Please check username or password again";


mysql_connect($host, $username, $password) or die($errorMessage);


mysql_select_db($dbname) or die ('No database found');


echo "Connected successfully";


?>

Screenshot :

Check MySQL database connection in PHP using script dynamically

Click here to download Check MySQL database connection in PHP using script dynamically project file with source code.

Leave a Reply

Your email address will not be published. Required fields are marked *