Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Test MySQL database connection with php script  (Read 2306 times)

0 Members and 1 Guest are viewing this topic.

Haripriya H

  • Guest
Test MySQL database connection with php script
« on: April 05, 2014, 10:49:17 am »
You can use the following php script which is used to test mysql database connection on your cpanel server.

Code: [Select]
<?php
$link = mysql_connect('db_host', 'db_username', 'db_password');
if (!$link)
{
die('Could not connect the database: ' . mysql_error());
}
echo 'Database Connected successfully';
mysql_close($link);
?>
Code: [Select]

db_host : Mostly used ‘localhost’ when you connect on the same server.

db_username : Use your test database username.

db_password : Use your test database password.

The above MySQL connection test script is using mysql_connect(); function which is designed to open a connection to a MySQL Server

That's All :)