Created
March 8, 2017 18:55
-
-
Save bradystone/59b02573da52ecee485d4b5b7b987eb6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| # Fill our vars and run on cli | |
| # $ php -f db-connect-test.php | |
| $dbname = 'name'; | |
| $dbuser = 'user'; | |
| $dbpass = 'pass'; | |
| $dbhost = 'host'; | |
| $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; | |
| while($tbl = mysql_fetch_array($result)) { | |
| $tblCnt++; | |
| #echo $tbl[0]."<br />\n"; | |
| } | |
| if (!$tblCnt) { | |
| echo "There Be No Tables Hither<br />\n"; | |
| } else { | |
| echo "Thou Hath Birthed $tblCnt Tables<br />\n"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment