PHP mysqli_select_db() Function

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

Object oriented style

bool mysqli::select_db ( string $dbname )

Procedural style

bool mysqli_select_db ( mysqli $link , string $dbname )

Selects the default database to be used when performing queries against the database connection.

Examples -

Object oriented style

Procedural style

The above examples will output:

Default database is test.
Default database is world.

ParameterDescription
linkProcedural style only: A link identifier returned by mysqli_connect() or mysqli_init()
dbnameThe database name.

Returns TRUE on success or FALSE on failure.