1
mysqli를 사용하여 mysql 테이블에 데이터를 삽입하려고하는데이 코드가 작동하지 않고 인쇄 된 오류가 없습니다.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();
}
?>
잘 모르겠지만 제공 한 코드 블록이 없으면 예기치 않은 파일 끝에 오류가 발생합니다. –