Forum und email

mysql_select_db

(PHP 4, PHP 5, PECL mysql:1.0)

mysql_select_db — Select a MySQL database

Descrierea

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

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.

Parametri

database_name

The name of the database that is to be selected.

link_identifier

Conexiunea MySQL. Dacă identificatorul legăturii nu este specificat, se presupune că este ultima legătură deschisă cu ajutorul mysql_connect(). Dacă nu este găsită nici o astfel de legătură, se va încerca crearea uneia prin apelul mysql_connect() fără argumente. În caz că nici o conexiune nu este găsită sau stabilită, se va genera o avertizare de nivelul E_WARNING.

Valorile întroarse

Întoarce valoarea TRUE în cazul succesului sau FALSE în cazul eşecului.

Exemple

Example#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());
}
?>

Note

Notă: Pentru compatibilitatea cu versiunile anterioare, următorul pseudonim dezaprobat poate fi utilizat: mysql_selectdb()