在阅读了有关 HY093 的所有其他问题后,我打开了这个问题以弄清楚为什么我也收到了这条消息.
After reading all others questions about the HY093, I open this one to figure out why I've got this message too.
这是我的桌子:
这是我的要求:(其中 $conn 是我的 PDO 连接)
And here is my request : (Where $conn is my PDO connection)
$sql = $conn->prepare("INSERT INTO Sites (Email,URL,Title,Description,PageRank,Rewrite,MetaDesc,Origin,BackLink,nbBackLink,RssTitle,RssAddress,SocAddress,SocPostalCode,SocCity,SocCountry,SocTel,Offer,Status,nbHit)
VALUES (:Email,:URL,:Title,:Description,:PageRank,:Rewrite,:MetaDesc,:Origin,:BackLink,0,:RssTitle,:RssAddress,:SocAddress,:SocPostalCode,:SocCity,:SocCountry,:SocTel,:Offer,:Status,0)");
$sql->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$pageRank = new GooglePageRank($_POST["site_url"]);
$sql->bindParam(":Email",$_POST["submail"],PDO::PARAM_STR);
$sql->bindParam(":URL",$_POST["site_url"],PDO::PARAM_STR);
$sql->bindParam(":Title",$_POST["site_title"],PDO::PARAM_STR);
$sql->bindParam(":Description",$_POST["site_desc"],PDO::PARAM_STR);
$sql->bindParam(":PageRank",$pageRank->PageRank,PDO::PARAM_INT);
$sql->bindParam(":Rewrite",stringToRewrite($_POST["site_title"]),PDO::PARAM_STR);
$sql->bindParam(":MetaDesc",$_POST["site_desc"],PDO::PARAM_STR);
$sql->bindParam(":Origin",$_POST["site_country"],PDO::PARAM_STR);
$sql->bindParam(":BackLink",$_POST["site_backlink"],PDO::PARAM_STR);
$sql->bindParam(":RssTitle",$_POST["site_rss_title"],PDO::PARAM_STR);
$sql->bindParam(":RssAddress",$_POST["site_rss_addr"],PDO::PARAM_STR);
$sql->bindParam(":SocAddress",$_POST["soc_addr"],PDO::PARAM_STR);
$sql->bindParam(":SocPostalCode",$_POST["soc_cp"],PDO::PARAM_STR);
$sql->bindParam(":SocCity",$_POST["soc_city"],PDO::PARAM_STR);
$sql->bindParam(":SocCoutry",$_POST["soc_pays"],PDO::PARAM_STR);
$sql->bindParam(":SocTel",$_POST["soc_tel"],PDO::PARAM_STR);
$offer = $_POST["offer"] == "premium" ? 1 : 0;
$status = $_POST["offer"] == "premium" ? 2 : 0;
$sql->bindParam(":Offer",$offer,PDO::PARAM_INT);
$sql->bindParam(":Status",$status,PDO::PARAM_INT);
$sql->execute();
var_dump($sql->errorInfo());
var_dump($sql->errorCode());
知道为什么我一直有 HY093 错误吗?
Any idea why I keep have an HY093 error?
你的 bindParams 中有一个拼写错误,这意味着你的参数不匹配:
You have a typo in one of your bindParams, which means you have a mismatch in parameters:
$sql->bindParam(":SocCoutry",$_POST["soc_pays"],PDO::PARAM_STR);
应该是
$sql->bindParam(":SocCountry",$_POST["soc_pays"],PDO::PARAM_STR);
这篇关于带有 MySQL 插入 PDO 请求的错误 HY093的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!