简体   繁体   English

SQL绑定变量错误

[英]SQL Bound variables error

I'm getting the error in my code. 我的代码中出现错误。 I'm sure this means there is something wrong with the column=:variable section of my code, but I've gone over it and can't see what's wrong. 我确定这意味着我的代码的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:\...

Here is the code (long first line): 这是代码(第一行很长):

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

EDIT: image_link needed to be :image_link, still getting the same error 编辑:image_link需要是:image_link,仍然得到相同的错误

EDIT 2: Had a lot wrong, was using two names $sql and $stmt, using bindValue instead of bindParam 编辑2:有很多错误,正在使用两个名称$ sql和$ stmt,使用bindValue而不是bindParam

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQL 错误:SQLSTATE[HY093]:无效参数号:绑定变量数与令牌数不匹配 - SQL ERROR: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens PDO没有参数绑定sql错误 - PDO no parameter bound sql error PDO错误:绑定变量不匹配 - PDO error: bound variables do not match PHP绑定变量,无效的参数编号错误或PDO更新语句 - PHP bound variables, Invalid parameter number error or PDO Update Statement 异常 SQL STATE [ HY093 ] :无效的参数号:绑定变量的数量与令牌数量不匹配 - Exception SQL STATE [ HY093 ] : Invalid parameter number: number of bound variables does not match number of tokens 无效的参数编号:绑定变量的数量与令牌的数量不匹配SQL - Invalid parameter number: number of bound variables does not match number of tokens SQL SQL下界? - SQL Lower Bound? 使用bindParam的pdo更新显示绑定变量的错误数量与令牌数量不匹配 - pdo update using bindParam show the error number of bound variables does not match number of tokens 构建动态查询时,绑定变量数与令牌数不匹配 - Number of bound variables does not match number of tokens error when building dynamic query 错误:SQLSTATE[HY093]:无效的参数号:绑定变量的数量与标记的数量不匹配 - ERROR: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM