2015-09-27 89 views
0

一個更好的標題可能是「我不能指望」 :-(綁定變量的數不匹配的令牌數量 - ?

有什麼不對的代碼的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"

誰會讓我擺脫我的苦難&讓我說「哦!」 ?

回答

2

這是有點長的評論。我不知道爲什麼你會得到消息,但是你有這樣的片段在update

end_time:end_time 

這應該是

end_time = :end_time 

也許這將解決您的問題。

+0

如承諾:D'oh! – Mawg

相關問題