簡體   English   中英

SQL綁定變量錯誤

[英]SQL Bound variables error

我的代碼中出現錯誤。 我確定這意味着我的代碼的column =:variable部分出了點問題,但是我已經看完了,看不到出什么問題了。

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();

編輯:image_link需要是:image_link,仍然得到相同的錯誤

編輯2:有很多錯誤,正在使用兩個名稱$ sql和$ stmt,使用bindValue而不是bindParam

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM