致命错误:未捕获的错误:在布尔值上调用成员函数close()

时间:2018-07-17 13:50:31

标签: php

在将详细信息表单html发送到数据库时出错

  

致命错误:未捕获错误:在I:\ xampp \ htdocs \ insert.php:38中对布尔值调用成员函数close():堆栈堆栈跟踪:#0 {main}抛出在I:\ xampp \ htdocs \ insert中.php行38

我的php代码是:

<?php
$Year = isset($_POST['Year']) ? $_POST['Year'] : '';
$class = isset($_POST['class']) ? $_POST['class'] : '';
$total = isset($_POST['total']) ? $_POST['total'] : '';
$od = $_POST['od'];
$personal = $_POST['personal'];
if (!empty($Year) || !empty($class) || !empty($total) || !empty($od) ||
!empty($personalCode) || !empty($personal)) {
 $host = "localhost";
    $dbYear = "root";
    $dbclass = "";
    $dbname = "eeeabs";
    //create connection
    $conn = new mysqli($host, $dbYear, $dbclass, $dbname);
    if (mysqli_connect_error()) {
     die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
    } else {
     //$SELECT = "SELECT Year and class From absentees Where Year = ? and class = ? Limit 1";
     $INSERT = "UPDATE absentees SET total=$total, od=$od, personal=$personal  WHERE Year = $Year AND class = $class";
     //Prepare statement
     /*$stmt = $conn->prepare($SELECT);
     $stmt->bind_param("is", $Year, $class);
     $stmt->execute();
     $stmt->bind_result($Year);
     $stmt->store_result();
     $rnum = $stmt->num_rows;
     if ($rnum==0) {
      $stmt->close();*/
      $stmt = $conn->prepare($INSERT);
      //$stmt->bind_param('isiii', $Year, $class, $total, $od, $personal);
      //$stmt->execute();
     //mysqli_query($conn, $INSERT) or die('Query 1 Failed: '.mysqli_error($conn));
      echo "New record inserted sucessfully";
     /*} 
     else {
      echo "Someone already inserted for this class already";
     }*/
     $stmt->close();
     $conn->close();
    }
} 
else {
 echo "All field are required";
 die();
}
?>

首先,我将从html中获取用户输入,然后将该值传递给php,然后将其输入数据库中

0 个答案:

没有答案