Jump to content


Photo

Echo databases


  • Please log in to reply
1 reply to this topic

#1 p.ross

p.ross
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 05 December 2005 - 10:12 PM

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.

#2 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 06 December 2005 - 12:08 AM

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";
}
?>


Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users