This function Drop (delete) a MySQL database.

Syntax: mysql_drop_db (database_name , connection )

Description:

The first argument “database_name” is Required.It specifies to drop the database.

The second argument “connection” is Optional. It specifies the MySQL connection to close. If not specified, the last connection opened by mysql_connect() is used.

It is preferable to use mysql_query() to issue a sql DROP DATABASE statement instead.

Example:
Code:

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

$sql = 'DROP DATABASE library';
if  (mysql_query($sql, $connection)) {
    echo "Database library was successfully dropped\n";
} else {
    echo 'Error dropping database: ' . mysql_error() . "\n";
}

Output:

Database library was successfully dropped

eXTReMe Tracker