daily pastebin goal
20%
SHARE
TWEET

Untitled

a guest Jun 8th, 2017 60 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 = 'name';
  5. $dbuser = 'user';
  6. $dbpass = 'pass';
  7. $dbhost = 'host';
  8. $connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
  9. mysql_select_db($dbname) or die("Could not open the db '$dbname'");
  10. $test_query = "SHOW TABLES FROM $dbname";
  11. $result = mysql_query($test_query);
  12. $tblCnt = 0;
  13. while($tbl = mysql_fetch_array($result)) {
  14.   $tblCnt++;
  15.   #echo $tbl[0]."<br />\n";
  16. }
  17. if (!$tblCnt) {
  18.   echo "There are no tables<br />\n";
  19. } else {
  20.   echo "There are $tblCnt tables<br />\n";
  21. }
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