我想從我的表中刪除一些行。但是,當我點擊刪除,這只是給我一個空白頁面。我很確定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