我想从我的表中删除一些行。但是,当我点击删除,这只是给我一个空白页面。我很确定id值和我的db连接。无法从数据库中删除行
这是我的代码:
// connect to the database
include('connect-db.php');
// confirm that the 'id' variable has been set
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
// get the 'id' variable from the URL
$id = $_GET['id'];
// delete record from database
if ($stmt = $mysqli->prepare("DELETE FROM my_table WHERE id = ? LIMIT 1")) {
$stmt->bind_param("i",$id);
$stmt->execute();
$stmt->close();
} else {
echo "ERROR: could not prepare SQL statement.";
}
$mysqli->close();
// redirect user after delete is successful
header("Location: Dashboard.php");
} else {
// if the 'id' variable isn't set, redirect the user
header("Location: Dashboard.php");
}
你能[打开错误报告](http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php),看看你得到什么错误? – Chris