更好的标题可能是"我无法计算" : - (
这段代码有什么问题?它应该是显而易见的,但是我无法看到它。
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"
。
谁会把我从痛苦中解脱出来?让我说" D'哦!" ?
答案 0 :(得分:2)
评论有点长。我不知道为什么你会得到那条消息,但是你在update
中有这个片段:
end_time:end_time
这应该是
end_time = :end_time
也许这会解决你的问题。