Easy Tutorial
❮ Func Mysqli Field Count Func Xml Parser Free ❯

PHP mysqli_select_db() Function

PHP MySQLi Reference Manual

Change the default database for the connection:

Delete Database

<?php 
// Assume database username: root, password: 123456, database: tutorialpro 
$con = mysqli_connect("localhost", "root", "123456", "tutorialpro"); 
if (mysqli_connect_errno($con)) 
{ 
    echo "Failed to connect to MySQL: " . mysqli_connect_error(); 
} 

// ...some PHP code to query the "tutorialpro" database...

// Change database to "test"
mysqli_select_db($con, "test");

// ...some PHP code to query the "test" database...

mysqli_close($con);
?>

Definition and Usage

The mysqli_select_db() function is used to change the default database for the connection.


Syntax

Parameter Description
connection Required. Specifies the MySQL connection to use.
dbname Required. Specifies the default database to be used.

Technical Details

Return Value: Returns TRUE on success or FALSE on failure.
PHP Version: 5+
--- ---
❮ Func Mysqli Field Count Func Xml Parser Free ❯