<?php
$link = mysql_connect(‘localhost’, ‘root’, ”);
if (!$link) {
die(‘Could not connect: ‘ . mysql_error());
}
echo ‘Connected successfully’;
mysql_close($link);
?>
<br>数据库名称:
<?php
error_reporting(E_ALL);
$link = mysql_connect(‘localhost’, ‘root’, ”);
$db_list = mysql_list_dbs($link);
$i = 0;
$cnt = mysql_num_rows($db_list);
while ($i < $cnt) {
echo mysql_db_name($db_list, $i) . “n”;
$i++;
}
?>
<?php
mysql_connect(“localhost”, “root”, “”);
$result = mysql_list_tables(“mysql”);
for ($i = 0; $i < mysql_num_rows($result); $i++)
printf (“<br>Table: %sn”, mysql_tablename($result, $i));
mysql_free_result($result);
?>
文章来源:http://www.php.net/manual/zh/function.mysql-tablename.php