简体   繁体   中英

PDO Invalid Bound Parameter Number

So, I'm getting the following error using PHP's PDO:

SQLSTATE[HY093]: Invalid parameter number: parameter was not defined

Now, as far as I understand, this error only occurs when a parameter is used in a query, but then never properly bound. Typos, for example, make this a common error.

The problem is... I can't seem to find the issue! I've gone through each parameter several times, and can't find any disparities. Could something else be causing this issue? Am I just scrolling over an obvious typo that requires a second set of eyes to see? Any help would be hugely appreciated! Note that the error is occurring on the execute() , if that matters to you.

$sth = $dbh->prepare("
    INSERT INTO administrators
    (
        org_id,
        admin_email,
        passwd,
        passwd_salt,
        announcements,
        logo,
        design,
        content,
        layout,
        services,
        contributions_edit,
        contributions_report,
        contributions_enable,
        pledges,
        calendar,
        event,
        survey,
        email,
        caller,
        bulletin,
        prayer,
        email_newsletter,
        member_add,
        member_edit,
        passwd_reset,
        spotlight,
        profile_status,
        groups,
        attendance,
        sermons,
        church_info,
        mail_merge,
        file_upload,
        admin_name,
        administrators,
        newsletter,
        outreach,
        charts,
        streaming
    )
    VALUES
    (
        :org_id,
        :admin_email,
        :passwd,
        :passwd_salt,
        :announcements,
        :logo,
        :design,
        :content,
        :layout,
        :services,
        :contributions_edit,
        :contributions_report,
        :contributions_enable,
        :pledges,
        :calendar,
        :event,
        :survey,
        :email,
        :caller,
        :bulletin,
        :prayer,
        :email_newsletter,
        :member_add,
        :member_edit,
        :passwd_reset,
        :spotlight,
        :profile_status,
        :groups,
        :attendance,
        :sermons,
        :church_info,
        :mail_merge,
        :file_upload,
        :admin_name,
        :administrators,
        :newsletter,
        :outreach,
        :charts,
        :streaming
    )
    ");
$sth->bindParam(':org_id,', $org_id);
$sth->bindParam(':admin_email', $admin_email);
$sth->bindParam(':passwd', $passwd);
$sth->bindParam(':passwd_salt', $passwd_salt);
$sth->bindParam(':announcements', $announcements);
$sth->bindParam(':logo', $logo);
$sth->bindParam(':design', $design);
$sth->bindParam(':content', $content);
$sth->bindParam(':layout', $layout);
$sth->bindParam(':services', $services);
$sth->bindParam(':contributions_edit', $contributions_edit);
$sth->bindParam(':contributions_report', $contributions_report);
$sth->bindParam(':contributions_enable', $contributions_enable);
$sth->bindParam(':pledges', $pledges);
$sth->bindParam(':calendar', $calendar);
$sth->bindParam(':event', $event);
$sth->bindParam(':survey', $survey);
$sth->bindParam(':email', $email);
$sth->bindParam(':caller', $caller);
$sth->bindParam(':bulletin', $bulletin);
$sth->bindParam(':prayer', $prayer);
$sth->bindParam(':email_newsletter', $email_newsletter);
$sth->bindParam(':member_add', $member_add);
$sth->bindParam(':member_edit', $member_edit);
$sth->bindParam(':passwd_reset', $passwd_reset);
$sth->bindParam(':spotlight', $spotlight);
$sth->bindParam(':profile_status', $profile_status);
$sth->bindParam(':groups', $groups);
$sth->bindParam(':attendance', $attendance);
$sth->bindParam(':sermons', $sermons);
$sth->bindParam(':church_info', $church_info);
$sth->bindParam(':mail_merge', $mail_merge);
$sth->bindParam(':file_upload', $file_upload);
$sth->bindParam(':admin_name', $admin_name);
$sth->bindParam(':administrators', $administrators);
$sth->bindParam(':newsletter', $newsletter);
$sth->bindParam(':outreach', $outreach);
$sth->bindParam(':charts', $charts);
$sth->bindParam(':streaming', $streaming);
$sth->execute();

Thanks so much!

$sth->bindParam(':org_id,', $org_id);
                        ^
                        |
                        |_____________ This , is intentional? i guess not.

$sth->bindParam(':admin_email', $admin_email);
$sth->bindParam(':passwd', $passwd);
$sth->bindParam(':passwd_salt', $passwd_salt);
$sth->bindParam(':announcements', $announcements);
$sth->bindParam(':logo', $logo);
$sth->bindParam(':design', $design);
$sth->bindParam(':content', $content);
$sth->bindParam(':layout', $layout);
$sth->bindParam(':services', $services);
$sth->bindParam(':contributions_edit', $contributions_edit);
$sth->bindParam(':contributions_report', $contributions_report);
$sth->bindParam(':contributions_enable', $contributions_enable);
$sth->bindParam(':pledges', $pledges);
$sth->bindParam(':calendar', $calendar);
$sth->bindParam(':event', $event);
$sth->bindParam(':survey', $survey);
$sth->bindParam(':email', $email);
$sth->bindParam(':caller', $caller);
$sth->bindParam(':bulletin', $bulletin);
$sth->bindParam(':prayer', $prayer);
$sth->bindParam(':email_newsletter', $email_newsletter);
$sth->bindParam(':member_add', $member_add);
$sth->bindParam(':member_edit', $member_edit);
$sth->bindParam(':passwd_reset', $passwd_reset);
$sth->bindParam(':spotlight', $spotlight);
$sth->bindParam(':profile_status', $profile_status);
$sth->bindParam(':groups', $groups);
$sth->bindParam(':attendance', $attendance);
$sth->bindParam(':sermons', $sermons);
$sth->bindParam(':church_info', $church_info);
$sth->bindParam(':mail_merge', $mail_merge);
$sth->bindParam(':file_upload', $file_upload);
$sth->bindParam(':admin_name', $admin_name);
$sth->bindParam(':administrators', $administrators);
$sth->bindParam(':newsletter', $newsletter);
$sth->bindParam(':outreach', $outreach);
$sth->bindParam(':charts', $charts);
$sth->bindParam(':streaming', $streaming);
$sth->execute();

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