Advertisement
GWibisono

list database

Jan 26th, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.44 KB | None | 0 0
  1. $dbname = 'mysql_dbname';
  2.  
  3. if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) {
  4.     echo 'Could not connect to mysql';
  5.     exit;
  6. }
  7.  
  8. $sql = "SHOW TABLES FROM $dbname";
  9. $result = mysql_query($sql);
  10.  
  11. if (!$result) {
  12.     echo "DB Error, could not list tables\n";
  13.     echo 'MySQL Error: ' . mysql_error();
  14.     exit;
  15. }
  16.  
  17. while ($row = mysql_fetch_row($result)) {
  18.     echo "Table: {$row[0]}\n";
  19. }
  20.  
  21. mysql_free_result($result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement