我得到了这个非常简单的mysqli查询失败并返回此消息:
致命错误:未捕获错误:在M:\ xampp \ htdocs \ insert \ form-handler.php中调用boolean上的成员函数bind_param():17堆栈跟踪:#0 {main}抛出M:\ xampp第17行\ htdocs \ insert \ form-handler.php
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();
我有什么遗漏的吗?感谢。
答案 0 :(得分:0)
public class Bill{
...
public String getKey(){
return date.toString()+payedTo;
}
}
HahsMap<String,Bill> oldBills = ...
for (Bill bill : bills){
if (! oldBills.containsKey(bill.getKey()){
oldBill.put(bill.getKey(),bill)
}
}
从$stmt = $mysqli->prepare('INSERT INTO users (id, firstname, lastname) VALUES ("", ?, ?)');
中删除了!
,但您错过$stmt
以关闭)