PHP 8.3.4 Released!

mysql_create_db

(PHP 4, PHP 5)

mysql_create_dbCreate a MySQL database

Avviso

This function was deprecated in PHP 4.3.0, and it and the entire original MySQL extension was removed in PHP 7.0.0. Instead, use either the actively developed MySQLi or PDO_MySQL extensions. See also the MySQL: choosing an API guide. Alternatives to this function include:

Descrizione

mysql_create_db(string $database_name, resource $link_identifier = NULL): bool

mysql_create_db() attempts to create a new database on the server associated with the specified link identifier.

Elenco dei parametri

database_name

The name of the database being created.

link_identifier

La connessione MySQL. Se l'identificativo di connessione non è specificato, l'ultima connessione aperta da mysql_connect() viene assunta. Se questa connessione non è trovata, si cercherà di crearne una come se mysql_connect() fosse stata chiamata senza argomenti. Se una connessione non è trovata oppure non viene stabilita, un avviso di livello E_WARNING viene generato.

Valori restituiti

Restituisce true in caso di successo, false in caso di fallimento.

Esempi

Example #1 mysql_create_db() alternative example

The function mysql_create_db() is deprecated. It is preferable to use mysql_query() to issue an sql CREATE DATABASE statement instead.

<?php
$link
= mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!
$link) {
die(
'Could not connect: ' . mysql_error());
}

$sql = 'CREATE DATABASE my_db';
if (
mysql_query($sql, $link)) {
echo
"Database my_db created successfully\n";
} else {
echo
'Error creating database: ' . mysql_error() . "\n";
}
?>

Il precedente esempio visualizzerà qualcosa simile a:

Database my_db created successfully

Note

Nota:

Per la compatibilità all'indietro, i seguenti sinonimi (deprecati) possono essere utilizzati: mysql_createdb()

Nota:

This function will not be available if the MySQL extension was built against a MySQL 4.x client library.

Vedere anche:

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top