Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么我看到一个;无效的参数编号";使用命名参数时出错?_Php_Mysql_Pdo - Fatal编程技术网

Php 为什么我看到一个;无效的参数编号";使用命名参数时出错?

Php 为什么我看到一个;无效的参数编号";使用命名参数时出错?,php,mysql,pdo,Php,Mysql,Pdo,使用PDO执行此SQL查询时出现以下错误: 无效的参数编号:未定义参数 我看不到我需要在代码中更改什么 这是我的密码: $req = $this->manager->dao->prepare('UPDATE pronostics SET draw_lottery = :drawLottery, result_rank = :resultRank WH

使用PDO执行此SQL查询时出现以下错误:

无效的参数编号:未定义参数

我看不到我需要在代码中更改什么

这是我的密码:

$req = $this->manager->dao->prepare('UPDATE pronostics 
                                SET draw_lottery = :drawLottery, result_rank = :resultRank
                                WHERE draw_date = :drawDate AND id_user = :IdUser 
                                AND lottery_name = :lotteryName');

$req->bindParam(':idUser', $idUser, PDO::PARAM_INT);
$req->bindParam(':drawLottery', $drawLottery, PDO::PARAM_STR);
$req->bindParam(':resultRank', $resultRank, PDO::PARAM_INT);
$req->bindParam(':drawDate', $drawDate, PDO::PARAM_STR);        
$req->bindParam(':lotteryName', $lotteryName, PDO::PARAM_STR);
$req->execute();

您能告诉我缺少哪个参数吗?

bindParam字符串区分大小写,因此
:idUser
必须在查询和
bindParam
参数中以相同的方式大写

$req = $this->manager->dao->prepare('UPDATE pronostics 
                                    SET draw_lottery = :drawLottery, result_rank = :resultRank 
                                    WHERE draw_date = :drawDate AND id_user = :idUser AND lottery_name = :lotteryName');
$req->bindParam(':idUser', $idUser, PDO::PARAM_INT);                                    
$req->bindParam(':drawLottery', $drawLottery, PDO::PARAM_STR);
$req->bindParam(':resultRank', $resultRank, PDO::PARAM_INT);
$req->bindParam(':drawDate', $drawDate, PDO::PARAM_STR);
$req->bindParam(':lotteryName', $lotteryName, PDO::PARAM_STR);
$req->execute();

在你的
更新
查询中,你说的是
和id\u user=:IdUser
,而在定义参数时,可以看到名称不同
$req->bindParam(':IdUser'
),我相信这是错误的。它应该与查询
$req->bindParam(':IdUser'
中提到的相同