0
我得到了這個非常簡單的mysqli查詢失敗並返回此消息:的mysqli插入錯誤 - 調用一個成員函數bind_param
Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in M:\xampp\htdocs\insert\form-handler.php:17 Stack trace: #0 {main} thrown in M:\xampp\htdocs\insert\form-handler.php on line 17
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="form-handler.php" method="POST">
<input type="text" name="firstname">
<input type="text" name="lastname">
<input type="submit">
</form>
</body>
</html>
PHP:
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$mysqli = new mysqli('localhost', 'root', '', 'firstlast');
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$stmt = $mysqli->prepare('INSERT INTO users (id, firstname, lastname) VALUES ("", ?, ?');
$stmt->bind_param('ss', $firstname, $lastname);
$stmt->execute();
$stmt->close();
有什麼我錯過了?謝謝。
大地獄'!$語句='??? – AbraCadaver
@AbraCadaver的!最近被添加了,所以它不是原因。 –