MSL insert Query not working in PHP

时间:2017-07-12 08:15:25

标签: php sql

I have the following code but its not working no new entry is created in the database + its returning error, I cannot get the query to execute.

$query = "INSERT INTO request_send ('message,create_time,sdate,edate,guest,from_userid,to_userid,hostid') VALUES(':ms,:create_tim,:sdat,:edat,:gues,:from_useri,:to_useri,:hosti')";
$stmt = $DBcon->prepare( $query );
        $stmt ->bindParam(':ms', $req);
        $stmt->bindParam(':create_tim', $c_time);
        $stmt->bindParam(':sdat', $start);
        $stmt->bindParam(':edat', $end);
        $stmt->bindParam(':gues', $guest);
        $stmt->bindParam(':from_useri', $fromid);
        $stmt->bindParam(':to_useri', $touser);
        $stmt->bindParam(':hosti', $hostid);
        $stmt->bindParam(':whoareyou', $whoareyou);
     // check for successfull query
        if ( $stmt->execute() ){
             $response['status'] = 'success';
           } else {
                $response['status'] = 'error';
}

Help me to fix the issue. [edit] managed to solve it after rewriting the query

1 个答案:

答案 0 :(得分:0)

You got an excess bind_param()

$stmt->bindParam(':whoareyou', $whoareyou);

Either remove it or add :whoareyou in the query