准备好的声明无效参数号

时间:2013-06-20 05:17:01

标签: php mysql prepared-statement

好吧所以我现在已经开始了一个小时,它说“无效的参数编号:绑定变量的数量与...中的令牌数量不匹配”我们将它们计算出来并且它们是正确的。有什么想法吗?

 $sql="insert into myTable (TicketID ,Priority, Status, Summary, Description, Category, Customer,
                AssignedGroup, AssignedTo, OpenedDate, ResolvedDate, ClosedDate, FinalDescription, RootCause, ResolutionCode)
               values(:tid,:pri,:stat,:summ,:descr,:cat,:cus,:assG,:assT,:opnDate,:resDate,:cloDate:,finDesc,:root,:resCode)";
        $stmt=$dbh->prepare($sql);

        $stmt->bindParam(':tid', $data[0]);
        $stmt->bindParam(':pri', $data[1]);
        $stmt->bindParam(':stat', $data[2]);
        $stmt->bindParam(':summ', $data[3]);
        $stmt->bindParam(':descr', $data[4]);
        $stmt->bindParam(':cat', $data[5]);
        $stmt->bindParam(':cus', $data[6]);
        $stmt->bindParam(':assG', $data[7]);
        $stmt->bindParam(':assT', $data[8]);
        $stmt->bindParam(':opnDate', $Odate);
        $stmt->bindParam(':resDate', $RDate);
        $stmt->bindParam(':cloDate', $CDate);
        $stmt->bindParam(':finDesc', $data[12]);
        $stmt->bindParam(':root', $data[13]);
        $stmt->bindParam(':resCode', $data[14]);

        try{
            $stmt->execute();
            $stmt->closeCursor();

2 个答案:

答案 0 :(得分:1)

您在查询中忘记了:

cloDate,:finDesc,
        ^ // here

答案 1 :(得分:1)

更改此部分: -

:cloDate:,finDesc

:cloDate,:finDesc