SQL 错误 PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: 绑定变量的数量与中的标记数量不匹配
Posted
技术标签:
【中文标题】SQL 错误 PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: 绑定变量的数量与中的标记数量不匹配【英文标题】:SQL Error PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in 【发布时间】:2018-03-31 15:11:40 【问题描述】:我有点迷茫,我只是尝试对 SQL 表中存在的所有列进行更新,但不知何故它总是向我显示以下错误消息:
警告:PDOStatement::execute(): SQLSTATE[HY093]: 参数号无效:绑定变量的数量与中的标记数量不匹配
我的更新如下所示:
if(isset($_POST["send"]))
$time = time();
$airdrop=$_REQUEST['airdroptitel'];
$airdropcapped=$_REQUEST['airdropcapped'];
$airdrop_rating=$_REQUEST['airdroprating'];
$airdrop_type=$_REQUEST['airdroptype'];
$airdrop_freetext=$_REQUEST['airdrop_freetext'];
$airdrop_freetext_de=$_REQUEST['airdrop_freetext_de'];
$enddate_distribution=$_REQUEST['enddate_distribution'];
$projectdescription=$_REQUEST['projectdescribtion'];
$projecturl=$_REQUEST['projecturl'];
$reflink_layer=$_REQUEST['reflink_layer'];
$reflink_possible=$_REQUEST['reflink_possible'];
$projectname=$_REQUEST['projectname'];
$projectplattform=$_REQUEST['plattform'];
$bounty_usd=$_REQUEST['bounty'];
$bounty_cry=$_REQUEST['shortform'];
$bounty_cry_amount=$_REQUEST['bountyamount'];
$bounty_cry_refamount=$_REQUEST['refamount'];
$status=$_REQUEST['airdropstatus'];
$enddate=$_REQUEST['enddate'];
$who_change=$session_userid;
$timestamp_change=time();
$visible=$_REQUEST['showable'];
$ip_lastchange=$_SERVER['REMOTE_ADDR'];
$validation=$_REQUEST['validation'];
$totalsupply=$_REQUEST['totalsupply'];
$priceoftoken=$_REQUEST['priceoftoken'];
$telegramurl=$_REQUEST['telegramurl'];
$twitterurl=$_REQUEST['twitterurl'];
$mediumurl=$_REQUEST['mediumurl'];
$githuburl=$_REQUEST['githuburl'];
$facebookurl=$_REQUEST['facebookurl'];
$estimatedtime=$_REQUEST['estimatedtime'];
$hot=$_REQUEST['hot'];
$tool_telegram =$_REQUEST['tool_telegram'];
$tool_twitter =$_REQUEST['tool_twitter'];
$tool_facebook =$_REQUEST['tool_facebook'];
$tool_bitcointalk=$_REQUEST['tool_bitcointalk'];
$tool_mail =$_REQUEST['tool_mail'];
$tool_medium =$_REQUEST['tool_medium'];
$tool_linkedin =$_REQUEST['tool_linkedin'];
$tool_reddit =$_REQUEST['tool_reddit'];
$tool_register =$_REQUEST['tool_register'];
$tool_kyc =$_REQUEST['tool_kyc'];
$tool_other =$_REQUEST['tool_other'];
$statement = $pdo->prepare("UPDATE ad_airdrops SET airdrop =: airdrop, airdropcapped =: airdropcapped, airdrop_rating =: airdrop_rating, projectdescription =: projectdescription, projecturl =: projecturl, projectname =: projectname, projectplattform =: projectplattform, bounty_usd =: bounty_usd, bounty_cry =: bounty_cry, bounty_cry_amount =: bounty_cry_amount, bounty_cry_refamount =: bounty_cry_refamount, tool_other =: tool_other, status =: status, enddate =: enddate, who_change =: who_change, timestamp_change =: timestamp_change, visible =: visible, reflink_layer =: reflink_layer, reflink_possible =: reflink_possible, airdrop_type =: airdrop_type, facebookurl =: facebookurl, airdrop_freetext =: airdrop_freetext, enddate_distribution =: enddate_distribution, validation =: validation, totalsupply =: totalsupply, priceoftoken =: priceoftoken, telegramurl =: telegramurl, twitterurl =: twitterurl, mediumurl =: mediumurl, githuburl =: githuburl, airdrop_freetext_de =: airdrop_freetext_de, estimatedtime =: estimatedtime, hot =: hot, tool_telegram =: tool_telegram, tool_twitter =: tool_twitter, tool_facebook =: tool_facebook, tool_bitcointalk =: tool_bitcointalk, tool_mail =: tool_mail, tool_medium =: tool_medium, tool_linkedin =: tool_linkedin, tool_reddit =: tool_reddit, tool_register =: tool_register, tool_kyc =: tool_kyc WHERE id =: id");
$statement->execute(array('airdrop' => $airdrop, 'airdropcapped' => $airdropcapped, 'airdrop_rating' => $airdrop_rating, 'projectdescription' => $projectdescription, 'projecturl' => $projecturl, 'projectname' => $projectname, 'projectplattform' => $projectplattform, 'bounty_usd' => $bounty_usd, 'bounty_cry' => $bounty_cry, 'bounty_cry_amount' => $bounty_cry_amount, 'bounty_cry_refamount' => $bounty_cry_refamount, 'tool_other' => $tool_other, 'status' => $status, 'enddate' => $enddate, 'who_change' => $who_change, 'timestamp_change' => $timestamp_change, 'visible' => $visible, 'reflink_layer' => $reflink_layer, 'reflink_possible' => $reflink_possible, 'airdrop_type' => $airdrop_type, 'facebookurl' => $facebookurl, 'airdrop_freetext' => $airdrop_freetext, 'enddate_distribution' => $enddate_distribution, 'validation' => $validation,'totalsupply' => $totalsupply, 'priceoftoken' => $priceoftoken, 'telegramurl' => $telegramurl, 'twitterurl' => $twitterurl, 'mediumurl' => $mediumurl, 'githuburl' => $githuburl, 'airdrop_freetext_de' => $airdrop_freetext_de, 'estimatedtime' => $estimatedtime, 'hot' => $hot, 'tool_telegram' => $tool_telegram, 'tool_twitter' => $tool_twitter, 'tool_facebook' => $tool_facebook, 'tool_bitcointalk' => $tool_bitcointalk, 'tool_mail' => $tool_mail, 'tool_medium' => $tool_medium, 'tool_linkedin' => $tool_linkedin, 'tool_reddit' => $tool_reddit, 'tool_register' => $tool_register, 'tool_kyc' => $tool_kyc, 'id' => $id));
如果有人可以帮助我,我会非常高兴,在这个问题上已经搜索了 2 个小时:/ 谢谢。
【问题讨论】:
冒号和参数名称之间的空格是什么(例如...githuburl =: githuburl
而不是...githuburl = :githuburl
)?
好问题,我不是专业人士;)我只是想边做边学。我现在删除了它们但没有改变,同样的错误消息。编辑。实际上它有所帮助,但现在没有节省......嗯
您应该编辑您的问题以包含您更新的代码。这样我们就可以找出真正的问题所在。 (尝试自己调试的一种方便方法:临时重写代码,以便只更新 one 列。它有效吗?)
我对 *** 还是很陌生。这个页面帮助我解决了我的问题。我会试试你的把戏并更新我的问题 - 谢谢!
【参考方案1】:
您在查询字符串中使用了endate_distribution
,在参数列表中使用了enddate_distribution
。
【讨论】:
谢谢!但仍然没有保存,我将再次检查所有列的拼写。 您是否仍然收到相同的错误消息,还是已经改变? 我现在没有收到任何错误消息 - 我的错误消息问题已通过更改“= :”得到解决。很抱歉让你们感到困惑,这只是我的第一个问题;)谢谢您的帮助 (PS:确保将这些冒号保留在参数名称旁边。您需要:airdrop
和:id
,而不是: airdrop
和: id
。)
哦,这真的只是空间 - 谢谢你最后的建议,这解决了我的问题:)以上是关于SQL 错误 PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: 绑定变量的数量与中的标记数量不匹配的主要内容,如果未能解决你的问题,请参考以下文章
ORACLE:错误错误(6,3):PL/SQL:SQL 语句被忽略和错误(8,3):PL/SQL:ORA-00933:SQL 命令未在过程中正确结束