The mysql_db_name() function is used to get the database name.
PHP mysql_db_name() Function Example:
The mysql_db_name() function is used to get the database name. It returns the database name on success, and FALSE on failure. If you want a list of the database name then use mysql_list_dbs() function.
Example:
<?php $connection = mysql_connect("localhost","root","root"); if (!$connection) { die('PHP Mysql database connection could not connect : ' . mysql_error()); } else{ $database_list = mysql_list_dbs($connection); $i = 0; $count = mysql_num_rows($database_list); while ($i < $count) { echo mysql_db_name($database_list, $i) . "\n<br/>"; $i++; } } ?>
The existing database on the this server is:
After running this example the output is:
Output:
The list of the database names like:
ntinet openinviter person1 php_mysql phpwork platform pressrelease_db
[ 0 ] Comments