转载自:http://www.phpweblog.net/haix/archive/2009/08/18/6852.html

<?php


phpinfo();

$db_connection = mysql_connect("localhost","root","110");
mysql_select_db("szcpost",$db_connection) or die("Cannot open database test");


// 读取当前数据库名 www.szcpost.com
function mysql_current_db()
{
    $r = mysql_query("SELECT DATABASE()") or die(mysql_error());
    return mysql_result($r,0);
}

function get_host_info()
{
    return mysql_get_host_info();
}

function get_client_info()
{
    return mysql_get_client_info();
}

$db_name = mysql_current_db();
echo $db_name;
?>