PDOStatement::execute(): SQLSTATE[HY093]: 参数编号无效:绑定变量的数量与中的标记数量不匹配
PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in
我在准备更新查询时遇到问题:
$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 个参数,你知道我为什么会收到错误吗?
谢谢
删除
上的撇号 '
authorID = :authorID',
author = :author',
这样就可以了:
authorID = :authorID,
author = :author,
我在准备更新查询时遇到问题:
$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 个参数,你知道我为什么会收到错误吗?
谢谢
删除
上的撇号'
authorID = :authorID',
author = :author',
这样就可以了:
authorID = :authorID,
author = :author,