Jump to content

PHP SHOW DATABASES


schutzy

Recommended Posts

Hello All,

I am (attempting to write) writing an admin web interface for a CMS and as usual my first hurdle that I have to jump appears on the first line of real code...:(

The admin's function is to allow simple database management for multiple mysql databases via a browser. The issue that I am having right now is that I am trying to retrieve the names of all of the mysql databases that have been created. Using the command line this is a simple SHOW DATABASE; However, the mysql_query doesn't return any values.

Here's the code:

$dbquery = mysql_query("SHOW DATABASES;");
$i = 0;
while ($row = mysql_fetch_assoc($dbquery)) {
$arr[$i] = $row['post_title'];
echo "<br> $i=$arr[$i]";
$i++ ;
}

This is probably a stupid post but what the heck

Schutzy


Link to comment
Share on other sites

This works for me, returns all the databases on the server...

[code]
$dbquery = mysql_query("SHOW DATABASES");

$i = 0;
while ($row = mysql_fetch_assoc($dbquery)) {
    $arr[$i] = $row['Database'];
    echo "<br> ". $i ." = " .$arr[$i];
    $i++;
}
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.