准备好的语句可用于SELECT,但不能用于DELETE吗?

时间:2018-11-29 15:47:05

标签: php html prepared-statement

所以我有以下代码:

$stmt = $conn->prepare("DELETE * FROM cmp204users WHERE username = ? AND password = ?");
    $stmt->bind_param("ss", $username1, $password1);
    $stmt->execute();
    if ($temp == '1111') {
        header("location: index.php");
    } else {
        header("location: homepage.html");
    }
        }

哪个在我的php网站上返回错误"Fatal error: Call to a member function bind_param() on boolean in /home/UAD/1701472/public_html/delete.php on line 26"

但是,当我将DELETE更改为SELECT时,它可以正常工作:

  if($stmt->fetch() > 0) {  
    $stmt->close();
    $stmt = $conn->prepare("SELECT * FROM cmp204users WHERE username = ? AND password = ?");
    $stmt->bind_param("ss", $username1, $password1);
    $stmt->execute();
    if ($temp == '1111') {
        header("location: index.php");
    } else {
        header("location: homepage.html");
    }
        }

在cmp204users表中也有一个“ admin”列,但是无论admin为空还是其中的内容,我仍要删除所选的行。我猜测问题可能与此有关?

我们将不胜感激:)

0 个答案:

没有答案