PDO无效的绑定参数编号

时间:2012-09-21 17:06:22

标签: php pdo

所以,我使用PHP的PDO得到以下错误:

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

现在,据我所知,当在查询中使用参数但从未正确绑定参数时,会发生此错误 。例如,错别字使这成为一个常见的错误。

问题是......我似乎无法找到问题!我已经多次浏览过每个参数,并且找不到任何差异。还有别的东西会导致这个问题吗?我只是滚动一个明显的拼写错误,需要第二眼看到?任何帮助将非常感谢!请注意,如果这对您很重要,则会在execute()上发生错误。

$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();

非常感谢!

1 个答案:

答案 0 :(得分:3)

$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();