本文介绍了SQLSTATE [HY093]:无效的参数编号:绑定变量的数量与令牌的数量不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码产生错误:
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
但是我数了数,没有丢失的冒号,并且所有绑定参数都在其中...是什么导致此错误?
But I counted, there are no missing colons and all the binding parameters are there... What is causing this error?
参考下面的代码:
try{
$pdo->beginTransaction();
$insert1 = $pdo->prepare("INSERT INTO spo (spo_prefix,datecreated,destinationID,vendorID,grade,flute,qty,wdat,ldat,scoreline,due,remark,isowarrant,area_m,area_ft,supplyIDs,qty_waste,expectedPrice) VALUES (:spoprefix,:nowdate,:location,:selvid,:cgrade,:cflute,:vendorqty,:wdat,:ldat,:scoreline,:duedate,:vendorremark,:iso,:squarem,:squareft,:siid,:wasteqty,:thisprice)");
$resultB = $pdo->prepare("SELECT vendorname FROM vendorDefinition WHERE id=:svid LIMIT 1");
$resultC = $pdo->prepare("SELECT destinationName FROM shipDestination WHERE id=:locationselect LIMIT 1");
$insert1->execute(array(":spoprefix"=>$_POST['SPOprefix'],
":nowdate"=>$nowdate,
":location"=>$_POST['locationselect'],
":selvid"=>$_POST['selectedVID'],
":cgrade"=>$_POST['const_grade'],
":cflute"=>$_POST['const_flute'],
":vendorqty"=>$_POST['vendorqty'],
":wdat"=>$wdat,
":ldat"=>$ldat,
":scoreline"=>$scoreline,
":duedate"=>$duedate,
":vendorremark"=>$_POST['vendorremark'],
":iso"=>"",
":squarem"=>$_POST['squaremeter'],
":squareft"=>$_POST['squarefeet'],
":siid",$_POST['const_siid'],
":wasteqty"=>$_POST['wasteqty'],
":thisprice"=>$_POST['thisprice']));
$resultB->execute(array(":svid"=>$_POST['selectedVID']));
$resultC->execute(array(":locationselect"=>$_POST['locationselect']));
$pdo->commit();
}catch(PDOException $e){
$pdo->rollBack();
die("<h1>ERROR" . $e);
}
推荐答案
问题在这里:
":siid",$_POST['const_siid'],
^--- should be "=>", not ","
这篇关于SQLSTATE [HY093]:无效的参数编号:绑定变量的数量与令牌的数量不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!