我无法在数据库中插入信息,这是什么问题?

时间:2019-11-12 20:28:33

标签: php mysql

你好,我有问题,我不明白什么是问题?

  

致命错误:未捕获错误:调用成员函数bind_param()   布尔值   C:\ xampp \ htdocs \ new_project \ public_html \ includes \ DBOperation.php:16   堆栈跟踪:#0   C:\ xampp \ htdocs \ new_project \ public_html \ includes \ DBOperation.php(29):   DBOperation-> addCategory(0,'Electronics')#1 {main}被抛出   C:\ xampp \ htdocs \ new_project \ public_html \ includes \ DBOperation.php在   第16行

class DBOperation {

 private $con;

 function __construct(){
    include_once("../database/db.php");
    $db = new DataBase();
    $this->con = $db->connect();
 }

 public function addCategory($parent,$cat){
    $pre_stmt = $this->con->prepare("INSERT INTO 'category' ('PARENT_CAT','CATEGORY_NAME','STATUS') VALUES(?,?,?)");
     $status = 1;
     $pre_stmt->bind_param("isi", $parent,$cat,$status);
     $result = $pre_stmt->execute() or die($this->con->error);

     if($result){
        return "CATEGORY_ADDED";
     }else{
        return 0;
     }
   }
 }


 $opr = new DBOperation();
 echo $opr->addCategory(0,'Electronics');

0 个答案:

没有答案