我创建了一个数据库'alphacrn',我想通过使用命令DROP来测试它
这是代码:
<?php
{ // Connect and Test MySQL and specific DB (return $dbSuccess = T/F)
$hostname = "localhost";
$username = "root";
$password = "";
$dbConnected = @mysql_connect($hostname, $username, $password);
$dbSuccess = true;
if ($dbConnected) {
} else {
echo "MySQL connection FAILED<br /><br />";
$dbSuccess = false;
}
}
// Execute code ONLY if connections were successful
if ($dbSuccess) {
$dbName = "alphacrn";
$drop_SQL = "DROP DATABASE " . $dbName;
if (mysql_query($drop_SQL)) {
echo "'DROP DATABASE " . $dbName . "' - Successful.";
} else {
echo "'DROP DATABASE " . $dbName . "' - Failed.";
}
}
?>
执行我的代码后,我收到回复:'DROP DATABASE alphacrn' - 失败。 我哪里做错了??就我而言,代码看起来很干净而且对我来说还可以。再加上数据库正在运行,没有任何问题......
我应该怎么做才能修复这个错误?
mysql错误:
echo "<br>"."<br>".mysql_error()."<br>"."<br>";
echo $drop_SQL;
浏览器中的结果:
'删除数据库 alphacrn' - 失败。
无法删除数据库 'alphacrn';数据库不存在
删除数据库字母