Php Can';t从数据库中删除行

Php Can';t从数据库中删除行,php,database,mysqli,Php,Database,Mysqli,我想从表中删除一些行。但当我单击“删除”时,这只会显示一个空白页。我确定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 fro

我想从表中删除一些行。但当我单击“删除”时,这只会显示一个空白页。我确定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");
}

首先,我建议您使用$\u POST方法,您可以阅读更多有关它的信息


尝试使用bindValue()而不是bindParam(),我认为需要为bindParam()声明一些其他内容,我忘记了(我也是PHP新手)。

有一个类似的问题
. 基本上,您可以尝试直接在数据库中运行SQL,以查看是否出现任何错误。还要确认数据库用户具有删除权限,并且id作为整数存储在数据库中。

您可以查看一下您得到了什么错误吗?mysqli没有
bind_value()
方法。我在phpmyadmin中测试了mysqli查询,代码正常,但单击…/delete.php?id=?链接它什么也没给我,一片空白