用下列代码试试:
$data = array();
$dbname = '你要查询的表名';
mysql_connect('localhost', 'root', '') or die('Cann\'t connect server!');
$result = mysql_query('show databases;');
While($row = mysql_fetch_assoc($result)){
$data[] = $row['Database'];
}unset($result, $row);
mysql_close();
print_r($data);
if (in_array(strtolower($dbname), $data))
die('存在');
else
die('不存在');
?>