1

我的代码产生错误:

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

但是我数了一下,没有丢失冒号,所有绑定参数都在那里......是什么导致了这个错误?

参考下面的代码:

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

1 回答 1

4

问题在这里:

":siid",$_POST['const_siid'],
       ^--- should be "=>", not ","
于 2012-07-15T06:16:42.987 回答