【发布时间】:2014-04-08 14:00:10
【问题描述】:
我需要通过在下面给出的代码中传递 a 和 b 的值来删除数据库
我已将 a 的值设置为 5 用于第一级测试,将 b 设置为数据库名称
即 index.php?a=5&b=test
<?php
include ('config.php');
$a=$_GET["a"];
$b=$_GET["b"];
if ($a==5)
{
$sql = 'drop database'.'$db';
if (mysql_query($sql))
{
echo "Database test was successfully dropped\n";
}
else
{
echo 'Error dropping database: ' . mysql_error() . "\n";
}
}
{
echo "Not Success";
}
?>
我收到错误消息
Error dropping database: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'databasee$db' at line 1 Not Success
我知道我不能通过 php 中的 mysql 查询删除数据库
Error Dropping Database (Can't rmdir '.test\', errno: 17)
错误是在代码中包含数据库名称
$sql='drop database'.'$b';
我该怎么做?
【问题讨论】:
-
databsae 这是打字错误吗?
-
是的,这是一个打字错误,我编辑了它