Guest User

Untitled

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