因此,使用 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();
非常感谢!