PHP mysql_db_name() Function Example

PHP mysql_db_name() Function Example


Posted in : PHP Posted on : February 5, 2011 at 5:30 PM Comments : [ 0 ]

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

Download Example Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics