Jump to content

Archived

This topic is now archived and is closed to further replies.

p.ross

Echo databases

Recommended Posts

What is the code to echo the list of databases? I know in MySQL it's "SHOW DATABASES" but if you try to echo that query it's like systemresource #3 or something. Thanks.

Share this post


Link to post
Share on other sites

are you trying to print mysql_query? you have to use mysql_result or mysql_fetch_xxx to get the rows before printing.

 

the php alternative is mysql_list_dbs

<?php

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');

$db_list = mysql_list_dbs($link);

 

while ($row = mysql_fetch_object($db_list)) {

echo $row->Database . "\n";

}

?>

Share this post


Link to post
Share on other sites

×

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.