PDOStatement :: execute():SQLSTATE [HY093]:参数号无效:绑定变量的数量与令牌的数量不匹配

时间:2017-08-02 08:27:55

标签: pdo prepared-statement bind

我对准备好的更新查询有问题:

$stmt = $conn->prepare("
        UPDATE articles SET 
        title = :title, 
        body = :body, 
        intro = :intro, 
        datePub = :datePub, 
        authorID = :authorID', 
        author = :author', 
        category = :category, 
        tags = :tags, 
        language = :language, 
        visible = :visible, 
        translatedArt = :translatedArt, 
        relatedArts = :relatedArts, 
        priority = :priority, 
        changefreq = :changefreq
        WHERE 
        id= :id"
        );


        $stmt->bindParam(':title', $title, PDO::PARAM_STR);
        $stmt->bindParam(':body', $bodyArt, PDO::PARAM_STR);
        $stmt->bindParam(':intro', $intro, PDO::PARAM_STR);
        $stmt->bindParam(':datePub', $datePub, PDO::PARAM_INT);
        $stmt->bindParam(':authorID', $author, PDO::PARAM_INT);
        $stmt->bindParam(':author', $authorName, PDO::PARAM_STR);
        $stmt->bindParam(':category', $cat, PDO::PARAM_INT);
        $stmt->bindParam(':tags', $tags, PDO::PARAM_STR);
        $stmt->bindParam(':language', $language, PDO::PARAM_STR);
        $stmt->bindParam(':visible', $visibility, PDO::PARAM_INT);
        $stmt->bindParam(':translatedArt', $transArt, PDO::PARAM_INT);
        $stmt->bindParam(':relatedArts', $relArtCombi, PDO::PARAM_STR);
        $stmt->bindParam(':priority', $priority, PDO::PARAM_STR);
        $stmt->bindParam(':changefreq', $changeFreq, PDO::PARAM_STR);
        $stmt->bindParam(':id', $operation, PDO::PARAM_INT);

        $stmt->execute();

我绑定了15个变量,查询中有15个参数,您是否知道我为什么会收到错误?

由于

1 个答案:

答案 0 :(得分:1)

删除

上的撇号'
authorID = :authorID', 
author = :author', 

所以它可以是:

 authorID = :authorID, 
 author = :author,