List Databases
2003-02-17 00:16:03
Category: php:database
Description: List all databases availible in mysql.
Author: detour
Viewed: 2909
Rating: (11 votes)


<?php
  // listdb.php by detour@metalshell.com
  //
  // List all databases availible in mysql.
  //
  // http://www.metalshell.com/
  //
 
 
  $dbuser = "user";
  $dbpass = "pass";
  $dbhost = "localhost";
 
  echo('<html><head><title>Database List</title></head><body>');
  echo('<font face="arial" style="font-weight:bold">');
 
  // Connect to mysql
  $dbid = mysql_connect($dbhost, $dbuser, $dbpass);
 
  // Get the list.
  $db_list = mysql_list_dbs($dbid);
 
  echo('<H1>Availible Databases</H1>');
  // Process each row as an object.
  while($row = mysql_fetch_object($db_list)) {
    // Print out the database name.
    echo $row->Database . "<br>";
  }
 
  // Close connection.
  mysql_close($dbid);
 
  echo('</body></html>');
?>