include_once("MyDB_class.php");
require('../Bean/appointment_class.php');
 class AppointmentModle extends MyDB{
      public function addAppointment($appointment){
       $this->mysqli->query("set names gb2312");
        $query="insert into db_appointment (A_title,A_time,A_content,A_author) values (?,?,?,?)";        $stmt=$this->mysqli->prepare($query);
 $stmt->bind_param('sdss',$A_title,date("Y-m-d"),$A_content,$A_author);   报错     $A_title=$appointment->getA_title();
       // $A_time=$appointment->getA_time();
        $A_content=$appointment->getA_content();
        $A_author=$appointment->getA_author();
        //echo $A_title,$A_time,$A_author,$A_content;能正确输出内容
       // exit;
              $stmt->execute();
        if($stmt->affected_rows!=1){
     $this->printError("数据插入失败:".$stmt->error);
     return false;
    }
    else{
     return $this->mysqli->insert_id;    }
      } }

解决方案 »

  1.   

    次序问题
     //echo $A_title,$A_time,$A_author,$A_content;能正确输出内容
    但你在 $stmt->bind_param('sdss',$A_title,date("Y-m-d"),$A_content,$A_author);
    这些变量并不存在呀
      

  2.   

    能说明白点吗?提示出错Fatal error: Call to a member function bind_param() on a non-object in D:\PHP\wamp\www\ReporterStation\admin\AppointmentModel_class.php on line 18
      

  3.   

    这只呢给你说明你
     $this->mysqli->query("set names gb2312");
      $query="insert into db_appointment (A_title,A_time,A_content,A_author) values (?,?,?,?)";  $stmt=$this->mysqli->prepare($query);
    这几句有错误。
      

  4.   

    $this->mysqli->prepare($query);
    这个函数返回的值里没有
    bind_param这个方法
      

  5.   

    时间类型应该是字符串:"s"$stmt->bind_param('ssss',$A_title,date("Y-m-d"),$A_content,$A_author);表字段是否允许为空?$A_title,$A_content,$A_author有值吗?参考:function addInfor($ordPrice,$time,$sid,$cid){
    $sql = "INSERT INTO mis_order(cid,sid,ordTime,ordPrice) VALUES(?,?,?,?);";
    $stmt = $this->mysqli->prepare($sql);
    $stmt->bind_param("iiss",$cid,$sid,$time,$ordPrice);
    $stmt->execute();
    $stmt->store_result();
    $rows = $stmt->affected_rows;
    if($rows > 0){
    header("location:sysAction.php?index=0");
    }else{
    echo "订单信息添加失败!<br/>";
    }
    $stmt->close();
    $this->mysqli->close();
    }