توابع mysql_db_name() در PHP
تعریف و استفاده
The mysql_db_name() function retrieves the database name returned by the mysql_list_dbs() call.
Syntax
mysql_db_name(list,row,field)
Parameter | Description |
---|---|
list | Required.mysql_list_dbs() Calls the returned result pointer. |
row | Required. Specifies the row number in the result set. Starts from 0. |
field | Optional. Specifies the field name. |
Description
If successful, it returns the database name, and if it fails, it returns false. If false is returned, use mysql_error() to determine the type of error.
Example
<?php $con = mysql_connect("localhost", "peter", "abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } $db_list = mysql_list_dbs($con); $i = 0; $db_count = mysql_num_rows($db_list); while ($i < $db_count) { echo mysql_db_name($db_list, $i) . "<br />"; $i++; } mysql_close($con); ?>
Output similar to:
mysql customers movies