0

This is not working:

    try {
    $insert = $conn->prepare("INSERT INTO dmarc_header (version, org_name, email, extra_contact_info, report_id, `date_range-begin`, `date_range-end`, domain, adkim, aspf, p, sp, pct)
                                                VALUES (:version:, :org_name:, :email:, :extra_contact_info:, :report_id:, :begin:, :end:, :domain:, :adkim, :aspf, :p:, :sp:, :pct:)");
    $insert->execute(array( ":version:" => "a",
                            ":org_name:" => "b",
                            ":email:" => "c",
                            ":extra_contact_info:" => "d",
                            ":report_id:" => "e",
                            ":begin:" => 5,
                            ":end:" => 6,
                            ":domain:" => "f",
                            ":adkim:" => "g",
                            ":aspf:" => "h",
                            ":p:" => "i",
                            ":sp:" => "j",
                            ":pct:" => "k"));
    $header_id = $conn->lastInsertId();
}

however this does:

    try {
    $insert = $conn->prepare("INSERT INTO dmarc_header (version, org_name, email, extra_contact_info, report_id, `date_range-begin`, `date_range-end`, domain, adkim, aspf, p, sp, pct)
                                                VALUES ('a', 'b', 'c', 'd', 'e', 5, 6, 'f', 'g', 'h', 'i', 'j', 'k')");
    $insert->execute();
    $header_id = $conn->lastInsertId();
}

what do I do wrong? I checked the typos and also tried escapings, however no luck :(

EDIT: this works, but it still does not answer my question why initial try does not, any ideas?

try {
    $insert = $conn->prepare("INSERT INTO dmarc_header (version, org_name, email, extra_contact_info, report_id, `date_range-begin`, `date_range-end`, domain, adkim, aspf, p, sp, pct)
                                                VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
    $insert->execute(array( "a", "b", "c", "d", "e", 5, 6, "f", "g", "h", "i", "j", "k"));
    $header_id = $conn->lastInsertId();
}

0 Answers0