参数号无效:绑定变量数与令牌数不匹配

时间:2015-03-18 16:03:57

标签: mysql

让它以某种方式工作,不需要答案。谢谢大家。

function upBook($id)    {   
    $request    =   Slim::getInstance()->request(); 
    $body   =   $request->getBody();    
    $books  =   json_decode($body); 
    $sql    =   "UPDATE books SET 
                book_name=:book_name, 
                book_price=:book_price, 
                WHERE book_id=:id"; 
        try {   
            $db =   getConnection();    
            $stmt   =   $db->prepare($sql); 
            $stmt->bindParam("id",  $id);   
            $stmt->bindParam("book_name",   $books->book_name); 
            $books  =   $stmt->fetchObject();   
            $db =   null;   
            responseJson(json_encode($books),200);  
    }   catch(PDOException  $e) {   
}

每次我在控制台中获得的异常是:

{"error":{"text":SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens}}

0 个答案:

没有答案