Skip to content
HostClub
Get started

Hosting

PHP Script to Test MySQL Database Connectivity

Provided below is a simple PHP script to test MySQL database connectivity. The result of this script displays the names of the tables present within the specified database.

Sample Script

        <!--?
	$connect=mysql_connect("dbserver","dbuser","dbpassword") or die("Unable to Connect");
	mysql_select_db("dbname") or die("Could not open the db");
	$showtablequery="SHOW TABLES FROM dbname";
	$query_result=mysql_query($showtablequery);
	while($showtablerow = mysql_fetch_array($query_result))
	{
	echo $showtablerow[0]." ";
	} 
	?-->

Explanation about the variables used in the script:

  • dbserver: Mention the value as localhost for Linux Hosting (cPanel). For Windows Hosting (Plesk), MySQL Server IP needs to be mentioned.

  • dbname: Specify complete database name including the prefix. For example, reseloaq_mysql.

  • dbuser: Mention the database user associated with the database.

  • dbpassword: Mention the password for the above database user.

Need a hand with this?

Our team can do it with you. Contact support, open a ticket from your dashboard, or write to support@hostclub.in.

Cookie settings

Switch each kind on or off. You can change or withdraw your consent here at any time.

Necessary and functional

Keep you signed in, hold your cart, remember your country and currency, protect forms and payments, run the support chat and remember these choices. The site cannot work without them, so they are always on.

Always on

Analytics

Google Analytics counts visits and shows which pages are used, so we can improve them. Nothing is set until you switch this on.

Marketing

The Meta Pixel measures visits from our Facebook and Instagram ads.