Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <?php
  2. # Fill our vars and run on cli
  3. # $ php -f db-connect-test.php
  4. $dbname = getenv('MYSQL_DATABASE');
  5. $dbuser = getenv('MYSQL_USER');
  6. $dbpass = getenv('MYSQL_PASSWORD');
  7. $dbhost = getenv('MYSQL_SERVICE_NAME');
  8.  
  9. $connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
  10. mysql_select_db($dbname) or die("Could not open the db '$dbname'");
  11. $test_query = "SHOW TABLES FROM $dbname";
  12. $result = mysql_query($test_query);
  13. $tblCnt = 0;
  14. while($tbl = mysql_fetch_array($result)) {
  15. $tblCnt++;
  16. #echo $tbl[0]."<br />\n";
  17. }
  18. if (!$tblCnt) {
  19. echo "There are no tables<br />\n";
  20. } else {
  21. echo "There are $tblCnt tables<br />\n";
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement