array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'pt_BR', ), 'this' => array ( 0 => 'function.mysql-select-db.php', 1 => 'mysql_select_db', ), 'up' => array ( 0 => 'ref.mysql.php', 1 => 'Funções da MySQL', ), 'prev' => array ( 0 => 'function.mysql-result.php', 1 => 'mysql_result', ), 'next' => array ( 0 => 'function.mysql-set-charset.php', 1 => 'mysql_set_charset', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/mysql/functions/mysql-select-db.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5)
mysql_select_db — Select a MySQL database
Esta extensão tornou-se defasada a partir do PHP 5.5.0 e foi removida no PHP 7.0.0. Em vez disso, as extensões MySQLi ou PDO_MySQL devem ser usadas. Veja também o guia MySQL: escolhendo uma API. Alternativas a esta função incluem:
Sets the current active database on the server that's associated with the specified link identifier. Every subsequent call to mysql_query() will be made on the active database.
database_name
The name of the database that is to be selected.
link_identifier
A conexão MySQL. Se o
identificador da conexão não for especificado, a última conexão aberta por
mysql_connect() será usada. Se não houver uma conexão anterior,
haverá uma tentativa de criar uma como se mysql_connect() tivesse sido chamada
sem argumentos. Se nenhuma conexão for encontrada ou estabelecida, um erro de nível
E_WARNING
será gerado.
Exemplo #1 mysql_select_db() 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());
}
?>
Nota:
Para compatibilidade com versões anteriores, o seguinte apelido defasado pode ser usado: mysql_selectdb()