只有变量才能通过引用传递

时间:2017-11-10 09:58:27

标签: php

我看到同一主题有很多问题。但他们都没有帮助我。

我正在尝试填写表单并将数据发送到数据库。它正在抛出标题中显示的错误。

public function insertQuestion($data){
    // print_r($data);
    // exit;
    $this->connect();
    $sth = $this->dbh->prepare('INSERT into tbl_questions(excel_id, class_id, subject_id, book_id, question_stem, option1, option2, option3, option4, option5, option6, option_img_1, option_img_2,option_img_3, option_img_4, option_img_5, option_img_6, correct_answer,image_name, marks, difficulty_level,outcome,created_on,question_type) 
    VALUES(?,?,?,?,?,?,?,?,?,?,? ,?,?,?,?,?,?,?,?,?,?,?,?,?) ');

    $sth->bindParam(1,  $data["excel_id"], PDO::PARAM_STR, 30);
    $sth->bindParam(2,  $data["class"], PDO::PARAM_INT);
    $sth->bindParam(3,  $data["subject_id"], PDO::PARAM_INT);
    $sth->bindParam(4,  $data["book_id"], PDO::PARAM_INT);
    $sth->bindParam(5,  isset($data["questiontitle"])?$data["questiontitle"]:"" , PDO::PARAM_STR, 500);
    $sth->bindParam(6,  isset($data["option1"])?$data["option1"]:"", PDO::PARAM_INT);
    $sth->bindParam(7,  isset($data["option2"])?$data["option2"]:"", PDO::PARAM_INT);
    $sth->bindParam(8,  isset($data["option3"])?$data["option3"]:"", PDO::PARAM_INT);
    $sth->bindParam(9,  isset($data["option4"])?$data["option4"]:"", PDO::PARAM_INT);
    $sth->bindParam(10, isset($data["option5"])?$data["option5"]:"", PDO::PARAM_INT);
    $sth->bindParam(11, isset($data["option6"])?$data["option6"]:"", PDO::PARAM_INT);
    $sth->bindParam(12, isset($data["optionimage1"])?$data["optionimage1"]:"", PDO::PARAM_INT);
    $sth->bindParam(13, isset($data["optionimage2"])?$data["optionimage2"]:"", PDO::PARAM_INT);
    $sth->bindParam(14, isset($data["optionimage3"])?$data["optionimage3"]:"", PDO::PARAM_INT);
    $sth->bindParam(15, isset($data["optionimage4"])?$data["optionimage4"]:"", PDO::PARAM_INT);
    $sth->bindParam(16, isset($data["optionimage5"])?$data["optionimage5"]:"", PDO::PARAM_INT);
    $sth->bindParam(17, isset($data["optionimage6"])?$data["optionimage6"]:"", PDO::PARAM_INT);
    $sth->bindParam(18, $data["answer"], PDO::PARAM_STR, 500);
    $sth->bindParam(19, isset($data["answerimage"])?$data["answerimage"]:"", PDO::PARAM_STR, 500);
    $sth->bindParam(20, $data["mark"], PDO::PARAM_INT);
    $sth->bindParam(21, $data["difficulty_level"], PDO::PARAM_INT);
    $sth->bindParam(22, $data["outcome"], PDO::PARAM_STR,200);
    $sth->bindParam(23, date('Y-m-d'), PDO::PARAM_STR,8);
    $sth->bindParam(24, $data["type"], PDO::PARAM_STR,20);


    if($sth->execute()) {
        $id = $this->dbh->lastInsertId(); 
        return $this->getQuestion($id);
    } else {
        return false;
    }

}

error pic

请帮助,我该如何纠正此错误。

0 个答案:

没有答案