简体   繁体   中英

MySQL query: Invalid parameter number: parameter was not defined

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).

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)..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM