0

I'm trying to execute the following query and parameters in PHP PDO:

Query:

$query = " 
            UPDATE converts SET
                client_status = :client_status,
                date_client = :date_client,
                credit_status = :credit_status,
                credit = :new_credit,
                convert_type_sub = :convert_type_sub,
                system_status = :system_status
            WHERE
                external_key = :external_key AND
                client_username = :client_username AND
                client_status = :client_status_old";

Parameters:

$parameters = array(
                ":client_status" => "ACCEPTED",
                ":client_status_old" => "NOTHING",
                ":date_client" => date("Y-m-d H:i:s"),
                ":external_key" => DT($_POST["ek"]),
                ":client_username" => $_SESSION['user']['username'],
                ":credit_status" => "TAKEN",
                ":convert_type_sub" => "OCR",
                ":system_status" => "READY_FOR_DOCX",
                ":new_credit" => ($need + $row['credit']));

But I get this error:

ERROR: UPDATE converts SET client_status = :client_status, date_client = :date_client, credit_status = :credit_status, credit = :new_credit, convert_type_sub = :convert_type_sub, system_status = :system_status WHERE external_key = :external_key AND client_username = :client_username AND client_status = :client_status_old
SQLSTATE[HY093]: Invalid parameter number: parameter was not defined

I spent two hours on the query and parameters but couldn't figure out what is the problem! Where I miss something?

asDca21
  • 161
  • 1
  • 2
  • 9
  • I couldn't find any parameter which have same pointer so it's not duplicated. – asDca21 Sep 13 '16 at 11:48
  • `$parameters = array( ":client_status" => "ACCEPTED", ":date_client" => date("Y-m-d H:i:s"), ":credit_status" => "TAKEN", ":new_credit" => ($need + $row['credit']), ":convert_type_sub" => "OCR", ":system_status" => "READY_FOR_DOCX", ":external_key" => DT($_POST["ek"]), ":client_username" => $_SESSION['user']['username'], ":client_status_old" => "NOTHING");` check through this – Alive to die - Anant Sep 13 '16 at 11:52
  • @Anant Thank you but what is the difference? didn't you just reordered parameters? I tried it and got same error. – asDca21 Sep 13 '16 at 11:57
  • you have to check that `external_key" => DT($_POST["ek"]),` and ":client_username" => $_SESSION['user']['username'], and ":new_credit" => ($need + $row['credit'])); the variables you used in these are set and have some values – Alive to die - Anant Sep 13 '16 at 12:10

0 Answers0