<?php
// Usage without mysql_list_dbs()
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
$res = mysql_query("SHOW DATABASES");
while ($row = mysql_fetch_assoc($res)) {
echo $row['Database'] . "\n";
}
// Deprecated as of PHP 5.4.0
$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";
}
?>
The above example will output something similar to:
database1
database2
database3
Notes
See Also
mysql_db_name
mysql_select_db
20.7.2.5.33.
mysql_list_fields
Copyright 1997-2012 the PHP Documentation Group. [2230]
•
mysql_list_fields
List MySQL table fields
Description
resource mysql_list_fields(
string database_name,
string table_name,
resource link_identifier
=
=NULL);
Retrieves information about the given table name.
Original MySQL API (Mysql)
Note
For backward compatibility, the following deprecated alias may be used:
mysql_listdbs
Warning
This extension is deprecated as of PHP 5.5.0, and will be removed in the
future. Instead, the
MySQLi
also
MySQL: choosing an API
Alternatives to this function include:
SQL Query:
SHOW COLUMNS FROM sometable
or
PDO_MySQL
extension should be used. See
guide and
related FAQ
2285
for more information.
Need help?
Do you have a question about the 5.0 and is the answer not in the manual?
Questions and answers