PHP MySQL Delete Database
From w3cyberlearnings
Contents |
PHP MySQL Delete A Database
Delete a database will remove a database from the MySQL.
Syntax
$sql = "DROP DATABASE database_name"; mysql_query($sql, $connection);
Example 1
<?php define('HOST', 'localhost'); define('USER', 'root'); define('PASS', 'yeething'); define('DBNAME', 'woowood'); $connection = mysql_connect(HOST, USER, PASS); if (!$connection) { die("can not connect to the server!<br/>"); } else { $sql = "DROP DATABASE " . DBNAME; if (mysql_query($sql, $connection)) { echo "Deleted successfully<br/>"; } else { echo "Error deleting database: " . mysql_error() . "<br/>"; } } mysql_close($connection); ?>
Output
Deleted successfully