2015-05-11 86 views
0

我在我的代碼中收到錯誤。我確信這意味着我的代碼中的column =:variable部分出現了問題,但我已經檢查了它,看不到有什麼問題。SQL綁定變量錯誤

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in F:\... 

下面是代碼(長的第一線):

 $stmt = $dbh->prepare("UPDATE item_list SET quantity=:quantity, new_price=:newprice, image_link=:image_link, market_hash_name=:markethashname, last_update='1000-01-01 00:00:00', is_tradable='TEST', old_price=:oldprice WHERE item_name=:itemname AND (image_link IS NULL OR quantity IS NULL OR new_price IS NULL OR market_hash_name IS NULL OR last_update IS NULL OR is_tradable IS NULL OR old_price IS NULL)"); 
     $sql->bindParam(':quantity', $json2->quantity); 
     $sql->bindParam(':newprice', $json2->lowest_price); 
     $sql->bindParam('image_link', $image_link_full); 
     $sql->bindParam(':markethashname', urlencode($mydata->market_hash_name)); 
     $sql->bindParam(':oldprice', $json2->lowest_price); 
     $stmt->bindValue(':itemname', $mydata->market_name); 
     $stmt->execute(); 

編輯:圖片鏈接,仍然得到同樣的錯誤

編輯2:是需要的圖片鏈接有很多錯誤,使用了兩個名稱$ sql和$ stmt,使用bindValue而不是bindParam

+1

'image_link'應該是綁定的':image_link' – Alex

+0

@Alex謝謝,我只是修復了它,但我仍然遇到了錯誤。 – Mitch8910

+0

@Alex你能看看它還應該是什麼嗎? – Mitch8910

回答

1

您在bindParam語句中的'image_link'之前缺少冒號':'。

+0

感謝您的參與!我修好了,但我仍然收到錯誤,所以必須有更多。 – Mitch8910

+0

你能看看還有什麼可以的嗎? – Mitch8910

+0

也許bindValue與bindParam ?? – BWS