You are here : phpmysqlmysql_select_db

mysql_select_db() - mysql

Selects MySQL Database to work with.


Syntax

bool mysql_select_db ( string $database_name [, resource $link_identifier = NULL ] )


Example

<?php

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Not connected : ' . mysql_error());
}

// make foo the current db
$db_selected = mysql_select_db('foo', $link);
if (!$db_selected) {
    die ('Can't use foo : ' . mysql_error());
}
?>


Output / Return Value

Selects a mysql database to be used.


Limitations

This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0.


Alternatives / See Also

The MySQLi or PDO_MySQL Should be used.


Reference

http://php.net/manual/en/function.mysql-select-db.php