Advertisement
Guest User

Untitled

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