PHP mysqli_select_db()Functions
Change the default database of the connection:
Delete Database
//Assume database username: root, password: 123456, database: EXAMPLE
$con=mysqli_connect("localhost","root","123456","EXAMPLE");
if (mysqli_connect_errno($con))
{
echo "Connection to MySQL failed:" . mysqli_connect_error();
}
//...some PHP code querying the "EXAMPLE" database...
//Change the database to "test"
mysqli_select_db($con,"test");
//...some PHP code querying the "test" database...
mysqli_close($con);
Definition and Usage
The mysqli_select_db() function is used to change the default database of the connection.
Syntax
mysqli_select_db(connection,dbname);
| Parameters | Description |
|---|---|
| connection | Required. Specifies the MySQL connection to use. |
| dbname | Required. Specifies the default database to use. |
Technical Details
| Return Value: | Returns TRUE on success, or FALSE on failure. |
|---|---|
| PHP Version: | 5+ |
PHP MySQLi Reference Manual Other Extensions