这是我的代码。
<?php
session_start();
ob_start();
if(!isset($_SESSION['teacher'])){
header("location: index.php");
exit;
}
include('connection.php');
?>
<!DOCTYPE html>
<html>
<meta charset='utf-8' />
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 3</title>
<link rel="stylesheet" type='text/css' href="css/bootstrap.min.css" />
<style>
.well {
box-shadow: inset 0px 0px 5px 2px rgba(0,0,0,0.2);
background-repeat: repeat;
background-image: url('img/noise4.png');
}
table{
width: 100%;
border-collapse: collapse;
}
th, td{
border: 1px solid white;
padding: 5px 15px;
border-collapse: collapse;
}
thead tr{
background-color: #003333;
color: white;
}
tbody tr{
background-color: #007777;
color: white;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body>
<!-- CONTAINER STARTS -->
<div class="container">
<br /><br />
<div class="row">
<div class="col-sm-12 text-center">
<img src="img/logo.png" /><br /><br />
<h2>Online Student Performence Evaluation System</h2>
<h3>Teacher control panel</h3>
</div>
<p id="status">
<?php
if(isset($_GET['status'])){
if($_GET['status']=='successful'){
echo "<div class='alert alert-success text-center col-sm-6 col-sm-offset-3'>
<strong>Successful!</strong> You have been logged in.
</div>";
}
}
?>
</p>
</div><br />
<table class="text-center">
<?php
$qry = mysqli_prepare($mysqli, "SELECT teacher_id, teacher_name FROM teachers WHERE teacher_id = ?");
mysqli_stmt_bind_param($qry, "s", $_SESSION['teacher']);
mysqli_stmt_execute($qry);
mysqli_stmt_bind_result($qry, $teacher_id, $teacher_name);
mysqli_stmt_fetch($qry);
echo "<thead><tr><th class='text-center' colspan='2'>Teacher information</th></tr></thead>
<tbody>
<tr><td><strong>Id</strong></td><td>".$teacher_id."</td></tr>
<tr><td><strong>Name</strong></td><td>".$teacher_name."</td></tr>
</tbody>";
?>
</table><br /><br />
<div class="row well text-center">
<h4>Add elements</h4><br />
<div class="col-sm-6">
<button class="btn btn-primary" data-toggle="modal" data-target="#add_exam_questions"><span class="glyphicon "></span> Add examination questions</button><br /><br />
<button class="btn btn-primary" data-toggle="modal" data-target="#add_exam_MCQs"><span class="glyphicon "></span> Add examination MCQs</button><br /><br />
</div>
<div class="col-sm-6">
<button class="btn btn-primary" data-toggle="modal" data-target="#add_categories"><span class="glyphicon "></span> Add categories</button><br /><br />
<button class="btn btn-primary" data-toggle="modal" data-target="#add_subjects"><span class="glyphicon "></span> Add subjects</button><br /><br />
</div>
</div>
</div>
<!-- Add question html section starts -->
<div id="add_exam_questions" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add a new question</h4>
</div>
<div class="modal-body">
<form class="form" id="eform" role="form" method="post">
<div class="form-group row-fluid">
<div class="row">
<label class="col-sm-5 col-sm-offset-1 col-form-label" for="esubject">Subject code:</label><div class="col-sm-5 col-sm-offset-1"><input id="esubject" class="form-control" name="exam_subject" required></div><br /><br />
</div>
<div class="row">
<label class="col-sm-5 col-sm-offset-1 col-form-label" for="ename">Examination's name:</label><div class="col-sm-5 col-sm-offset-1"><input id="ename" class="form-control" name="exam_name" required></div><br /><br />
</div>
<div class="row">
<label class="col-sm-5 col-sm-offset-1 col-form-label" for="esession">Session:</label><div class="col-sm-5 col-sm-offset-1"><input id="esession" class="form-control" name="exam_session" required></div><br /><br />
</div>
<div class="row">
<label class="col-sm-5 col-sm-offset-1 col-form-label" for="equestionid">Examination's question ID:</label><div class="col-sm-5 col-sm-offset-1"><input id="equestionid" class="form-control" name="exam_question_id" required></div><br /><br />
</div>
<div class="row">
<label class="col-sm-5 col-sm-offset-1 col-form-label" for="equestion">Question:</label><div class="col-sm-5 col-sm-offset-1"><textarea id="equestion" class="form-control" name="exam_question" required></textarea></div><br /><br />
</div>
<div class="row">
<div class="col-sm-12 text-center"><button type="submit" class="btn btn-primary" name="add_question"><span class="glyphicon glyphicon-floppy-disk"></span> Done</button></div><br />
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Add question html section ends -->
<!-- Add MCQ html section starts -->
<div id="add_exam_MCQs" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add a new MCQ</h4>
</div>
<div class="modal-body">
<form class="form" id="eform" role="form" method="post">
<div class="form-group row-fluid">
<div class="row">
<label class="col-sm-5 col-sm-offset-1 col-form-label" for="esubject">Subject code:</label><div class="col-sm-5 col-sm-offset-1"><input id="esubject" class="form-control" name="exam_subject" required></div><br /><br />
</div>
<div class="row">
<label class="col-sm-5 col-sm-offset-1 col-form-label" for="ename">Examination's name:</label><div class="col-sm-5 col-sm-offset-1"><input id="ename" class="form-control" name="exam_name" required></div><br /><br />
</div>
<div class="row">
<label class="col-sm-5 col-sm-offset-1 col-form-label" for="esession">Session:</label><div class="col-sm-5 col-sm-offset-1"><input id="esession" class="form-control" name="exam_session" required></div><br /><br />
</div>
<div class="row">
<label class="col-sm-5 col-sm-offset-1 col-form-label" for="mlo">MCQ's learning outcome:</label><div class="col-sm-5 col-sm-offset-1"><input id="mlo" class="form-control" name="MCQ_learning_outcome" required></div><br /><br />
</div>
<div class="row">
<label class="col-sm-5 col-sm-offset-1 col-form-label" for="eMCQ">MCQ:</label><div class="col-sm-5 col-sm-offset-1"><textarea id="eMCQ" class="form-control" name="exam_MCQ" required></textarea></div><br /><br />
</div>
<div class="row">
<div class="col-sm-12 text-center"><button type="submit" class="btn btn-primary" name="add_MCQ"><span class="glyphicon glyphicon-floppy-disk"></span> Done</button></div><br />
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Add MCQ html section ends -->
<!-- Add exam html section starts -->
<div id="add_exams" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add a new examination</h4>
</div>
<div class="modal-body">
<form class="form" id="eform" role="form" method="post">
<div class="form-group row-fluid">
<div class="row">
<label class="col-sm-5 col-sm-offset-1 col-form-label" for="ename">Examination's name:</label><div class="col-sm-5 col-sm-offset-1"><input class="form-control" type="text" id="ename" name="exam_name" required /></div><br /><br />
</div>
<div class="row">
<label class="col-sm-5 col-sm-offset-1 col-form-label" for="esubject">Subject code:</label><div class="col-sm-5 col-sm-offset-1"><input class="form-control" type="text" id="esubject" name="exam_subject" maxlength="20" required /></div><br /><br />
</div>
<div class="row">
<label class="col-sm-5 col-sm-offset-1 col-form-label" for="esession">Session:</label><div class="col-sm-5 col-sm-offset-1"><select id="esession" class="form-control" name="exam_session" required><?php echo $sessionlist; ?></select></div><br /><br />
</div>
<div class="row">
<label class="col-sm-5 col-sm-offset-1 col-form-label" for="edate">Examination's date:</label><div class="col-sm-5 col-sm-offset-1"><input class="form-control" type="text" id="edate" name="exam_date" required /></div><br /><br /><br />
</div>
<div class="row">
<div class="col-sm-12 text-center"><button type="submit" class="btn btn-primary" name="add_question"><span class="glyphicon glyphicon-floppy-disk"></span> Done</button></div><br />
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Add exam html section ends -->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
<?php
// Add php section starts
// Add question php section starts
if(isset($_POST['add_question'])){
if(!empty($_POST['exam_subject']) && !empty($_POST['exam_name']) && !empty($_POST['exam_session']) && !empty($_POST['exam_question_id']) && !empty($_POST['exam_question'])){
$exam_subject = $_POST['exam_subject'];
$exam_name = $_POST['exam_name'];
$exam_session = $_POST['exam_session'];
$exam_question_id = $_POST['exam_question_id'];
$exam_question = $_POST['exam_question'];
$_POST['exam_subject']= NULL;
$_POST['exam_name']= NULL;
$_POST['exam_session']= NULL;
$_POST['exam_question_id']= NULL;
$_POST['exam_question']= NULL;
$qry = mysqli_prepare($mysqli, "INSERT INTO exam_questions(subject_code, exam_name, session, question_id, question) VALUES(?, ?, ?, ?, ?)");
mysqli_stmt_bind_param($qry, "sssss", $exam_subject, $exam_name, $exam_session, $exam_question_id, $exam_question);
if(mysqli_stmt_execute($qry)){
echo "<script>$('#status').html(".'"'."<div class='alert alert-success text-center col-sm-6 col-sm-offset-3'><strong>Successful!</strong> A new question has been added.</div>".'"'.");</script>";
}else{
echo "<script>$('#status').html(".'"'."<div class='alert alert-danger text-center col-sm-6 col-sm-offset-3'><strong>Failed!</strong> Try again.</div>".'"'.");</script>";
}
}else{
echo "<script>$('#status').html(".'"'."<div class='alert alert-warning text-center col-sm-6 col-sm-offset-3'><strong>Caution!</strong> Enter all the fields.</div>".'"'.");</script>";
}
}
//Add question php section ends
// Add MCQ php section starts
if(isset($_POST['add_MCQ'])){
if(!empty($_POST['exam_subject']) && !empty($_POST['exam_name']) && !empty($_POST['exam_session']) && !empty($_POST['MCQ_learning_outcome']) && !empty($_POST['exam_MCQ'])){
$exam_subject = $_POST['exam_subject'];
$exam_name = $_POST['exam_name'];
$exam_session = $_POST['exam_session'];
$MCQ_learning_outcome = $_POST['MCQ_learning_outcome'];
$exam_MCQ = $_POST['exam_MCQ'];
$_POST['exam_subject']= NULL;
$_POST['exam_name']= NULL;
$_POST['exam_session']= NULL;
$_POST['MCQ_learning_outcome']= NULL;
$_POST['exam_MCQ']= NULL;
$qry = mysqli_prepare($mysqli, "INSERT INTO exam_mcqs(subject_code, exam_name, session, subject_learning_outcome, mcq) VALUES(?, ?, ?, ?, ?)");
mysqli_stmt_bind_param($qry, "sssss", $exam_subject, $exam_name, $exam_session, $MCQ_learning_outcome, $exam_MCQ);
if(mysqli_stmt_execute($qry)){
echo "<script>$('#status').html(".'"'."<div class='alert alert-success text-center col-sm-6 col-sm-offset-3'><strong>Successful!</strong> A new MCQ has been added.</div>".'"'.");</script>";
}else{
echo "<script>$('#status').html(".'"'."<div class='alert alert-danger text-center col-sm-6 col-sm-offset-3'><strong>Failed!</strong> Try again.</div>".'"'.");</script>";
}
}else{
echo "<script>$('#status').html(".'"'."<div class='alert alert-warning text-center col-sm-6 col-sm-offset-3'><strong>Caution!</strong> Enter all the fields.</div>".'"'.");</script>";
}
}
//Add MCQ php section ends
// Add exam php section starts
if(isset($_POST['add_exam'])){
if(!empty($_POST['exam_name']) && !empty($_POST['exam_subject']) && !empty($_POST['exam_session']) && !empty($_POST['exam_date'])){
$exam_name = $_POST['exam_name'];
$exam_subject = $_POST['exam_subject'];
$exam_session = $_POST['exam_session'];
$exam_question_id = $_POST['exam_question_id'];
$question_learning_outcomes = $_POST['question_learning_outcomes'];
$_POST['exam_name']= NULL;
$_POST['exam_subject']= NULL;
$_POST['exam_session']= NULL;
$_POST['exam_question_id']= NULL;
$_POST['question_learning_outcomes']= NULL;
$qry = mysqli_prepare($mysqli, "INSERT INTO exams(exam_name, subject_code, session, exam_date) VALUES(?, ?, ?, ?)");
mysqli_stmt_bind_param($qry, "ssss", $exam_name, $exam_subject, $exam_session, $exam_date);
if(mysqli_stmt_execute($qry)){
echo "<script>$('#status').html(".'"'."<div class='alert alert-success text-center col-sm-6 col-sm-offset-3'><strong>Successful!</strong> A new examination has been added.</div>".'"'.");</script>";
}else{
echo "<script>$('#status').html(".'"'."<div class='alert alert-danger text-center col-sm-6 col-sm-offset-3'><strong>Failed!</strong> Try again.</div>".'"'.");</script>";
}
}else{
echo "<script>$('#status').html(".'"'."<div class='alert alert-warning text-center col-sm-6 col-sm-offset-3'><strong>Caution!</strong> Enter all the fields.</div>".'"'.");</script>";
}
}
//Add exam php section ends
// Add php section ends
// logout php section starts
if(isset($_POST['logout'])){
session_destroy();
header("location: index.php");
exit;
}
//logout php section ends
mysqli_close($mysqli);
ob_end_flush();
?>
问题和mcq插入代码提供了
警告:mysqli_stmt_bind_param()要求参数1为mysqli_stmt,在第310行的E:\ UniServerZ \ www \ ospes \ teacher.php中给出布尔值 警告:mysqli_stmt_execute()要求参数1为mysqli_stmt,在第311行的E:\ UniServerZ \ www \ ospes \ teacher.php中给出布尔值 错误
找不到任何错误。类似的代码在其他页面中工作正常。这有什么不对?