Last active
June 14, 2016 06:59
-
-
Save farindra/d56ee7a131fb852b8ad35370c16fafbf to your computer and use it in GitHub Desktop.
Mysql Database Connection Tester
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
#Ard Mysql DB Tester Ver. 1.0 By Eka | |
#https://gist.github.com/farindra/d56ee7a131fb852b8ad35370c16fafbf | |
$dbname = 'db'; | |
$dbuser = 'user'; | |
$dbpass = 'pass'; | |
$dbhost = 'localhost'; | |
$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'"); | |
mysql_select_db($dbname) or die("Could not open the db '$dbname'"); | |
$test_query = "SHOW TABLES FROM $dbname"; | |
$result = mysql_query($test_query); | |
$tblCnt = 0; | |
echo 'Ard Mysql DB Tester Ver. 1.0'."<br />\n"; | |
echo '===================================='."<br />\n"."<br />\n"; | |
while($tbl = mysql_fetch_array($result)) { | |
$tblCnt++; | |
echo $tbl[0]."<br />\n"; | |
} | |
if (!$tblCnt) { | |
echo "There are no tables<br />\n"; | |
} else { | |
echo '===================================='."<br />\n"."<br />\n"; | |
echo "There are $tblCnt tables<br />\n"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment