绑定变量的数不匹配的令牌数量 - ?
问题描述:
一个更好的标题可能是“我不能指望” :-(绑定变量的数不匹配的令牌数量 - ?
有什么不对的代码的MySQL它应该是有目共睹的,但我可以”吨看到它看着它。
if (isset($_GET['campaign_id']))
{
ChromePhp::log('API: request to update existing campaign "' . $campaignTitle . '"');
$sqlCommand = $pdo->prepare('UPDATE campaigns SET title=:title, description=:description, start_time=:start_time, end_time:end_time) WHERE (customer_id=:customer_id) AND (campaign_id=:campaign_id)');
$sqlCommand->bindParam(':campaign_id', $_GET['campaign_id']);
}
else
{
ChromePhp::log('API: request to add a new campaign "' . $campaignTitle . '"');
$sqlCommand = $pdo->prepare('INSERT INTO campaigns (customer_id, title, description, start_time, end_time) VALUES(:customer_id, :title, :description, :start_time, :end_time)');
}
$sqlCommand->bindParam(':customer_id', $customerId);
$sqlCommand->bindParam(':title', $campaignTitle);
$sqlCommand->bindParam(':description', $campaignDescription);
$sqlCommand->bindParam(':start_time', $startTimeStamp);
$sqlCommand->bindParam(':end_time', $endTimeStamp);
$sqlResult = DatabaseCommand($sqlCommand);
浏览到
http://localhost/api/addCampaign.php?customer=1&title=t&description=d&startTimeStamp=1443313713&endTimeStamp=1443313713&campaign_id=5
给人Message: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
浏览器的开发者控制台日志显示API: request to update existing campaign "t"
。
谁会让我摆脱我的苦难&让我说“哦!” ?
答
这是有点长的评论。我不知道为什么你会得到是消息,但是你有这样的片段在update
:
end_time:end_time
这应该是
end_time = :end_time
也许这将解决您的问题。
如承诺:D'oh! – Mawg