duannuochi3549 2018-09-13 20:38
浏览 173

MySQL查询:参数号无效:未定义参数

The query:

$sql = "UPDATE `course` SET 
    `courselocation_id` = :courselocation_id,
    `courselocation_period_id` = :courselocation_period_id,
    `start_date` = :start_date,
    `instructor_id` = :instructor_id,
    `edited_by` = :edited_by,
    `edited_at` = :edited_at
WHERE `id` = :id";

$params = [
    ":courselocation_id" => 4,
    ":courselocation_period_id" => 8,
    ":start_date" => "2018-09-17",
    ":instructor_id" => 17,
    ":edited_by" => 1,
    ":edited_at" => 1536828797,
    ":id" => 2533
];

$query = $db->prepare($sql);
$query->execute($params);

is executed normally, the data is written, but I get an error:

PHP Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in /path/to/script.php on line 188

Line 188 is actually the one with $query->execute($params)

How can I fix that?

Update:

It really looks like another query was the cause of this warning just like @RiggsFolly suggested. When i commented out this one, the other one was not executed and that's why it wen't 'under the radar'. The other query had a misspelled parameter (instead of :intitutionID there was :institutionId).

  • 写回答

1条回答 默认 最新

  • dongqing6661 2018-09-14 10:59
    关注

    It really looks like another query was the cause of this warning just like @RiggsFolly suggested. When i commented out this one, the other one was not executed and that's why it wen't 'under the radar'. The other query had a misspelled parameter (instead of :intitutionID there was :institutionId)..

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog