1
我试图插入数据到MySQL表使用mysqli但这段代码不工作,我没有得到任何错误打印出来。MySQLi没有插入表
我可能会错过什么?
<?php
// if the form was submitted
if($_POST){
// sql query
$sql2 = "INSERT INTO
t_incident_persons (IncidentID, PersonID, KeywordID, description)
VALUES
(?, ?, ?, ?)";
// if the statement was prepared
if($stmt2 = $mysqli->prepare($sql2)){
//bind the values,
$stmt2->bind_param(
"iiis",
$_POST['IncidentID'],
$_POST['PersonID'],
$_POST['KeywordID'],
$_POST['description']
);
// execute the insert query
if($stmt2->execute()){
header('Location: details.php');
exit;
$stmt2->close();
}else{
die("Unable to add an incident.");
}
}else{
die("Unable to prepare statement.");
}
// close the database
$mysqli->close();
}
?>
不知道我理解你,但没有你给出的代码块我得到一个错误:意外的文件结束。 – 2014-11-14 14:12:58