SHARE
TWEET

Untitled

a guest Apr 29th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top