What is mysql db name in PHP

In this article I am going to explain about mysql_db_name function in PHP.
  • 1711

PHP mysql_db_name() Function

The PHP mysql_db_name function returns database name from a call to mysql_list_dbs function.

Syntax of mysql_db_name function

mysql_db_name(list, row, field)


Parameters in
mysql_db_name function

It have three  parameter:
 

Parameter Description
data It specifies result pointer from the mysql_list_dbs function.
row It specifies index into result set.
field It specifies the field name.

Example of mysql_db_name function

<html>

<body>

<?php

$con=mysql_connect("localhost","gupta","sharad");

if(!$con)

{

die("Could not connect:". mysql_error());

}

$dbList= mysql_list_dbs($con);

$a=0;

$count=mysql_num_rows($dbList);

while($a < $count)

{

echo mysql_db_name($dbList, $a)."</br>";

$a++;

}

mysql_close($con);

?>

</body>

</html>


Output:

mysql-db-name-php.jpg

You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.