PHP mysqli_select_db() Function

PHP mysqli_select_db() function is used to select the default database for database queries.


bool mysqli_select_db(connection,db);

mysqli_select_db() Function Parameter

connection :Required parameter. The MySQL connection to be used
db :Required parameter. The default database to be used

mysqli_select_db() Function Return Value

Return Values :Returns TRUE on success or FALSE on failure.

mysqli_select_db() Function Example

$con = mysqli_connect("localhost","user","password","db");

if (mysqli_connect_errno())
	echo "Failed to connect to MySQL: " . mysqli_connect_error();

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