SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

我是研究僧i 提交于 2020-01-06 03:00:07

问题


My code produces the error:

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?

Reference the Code Below:

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);
 }

回答1:


Problem is here:

":siid",$_POST['const_siid'],
       ^--- should be "=>", not ","


来源:https://stackoverflow.com/questions/11489714/sqlstatehy093-invalid-parameter-number-number-of-bound-variables-does-not-ma

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!