无法弄清楚以下错误

时间:2014-11-03 09:13:00

标签: php mysql

解析错误:语法错误,意外&#39 ;;'在第13行的C:\ xampp \ htdocs \ cart \ admin \ addtocart.php

这是我的代码,

<?php
if(isset($_POST['id'])){
        $pid=$_POST['id'];
        $wasFound=false;
        $i=0;
        if(!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1){
            $_SESSION["cart_array"]=array(0=>array("item_id"=>$pid,"quantity"=>1));
        }else{
            foreach($_SESSION["cart_array"] as $each_item){
                $i++;
                while(list($key,$value)=each($each_item)){
                if($key=="item_id" && $value==$pid){
                    array_splice($_SESSION["cart_array"],$i-1,1,array(array("item_id"=>$pid,"quantity"=>$each_item['quantity']+1));
                    $wasFound=true;
                }
            }
        }
        if($wasFound==false){
            array_push($_SESSION["cart_array"],array("item_id"=>$pid,"quantity"=>1));
        }
    }
    header("location:cart.php");
    exit();
}
?>

1 个答案:

答案 0 :(得分:-1)

你错过了最后一次结束&#39;)&#39;在下面的行

array_splice($_SESSION["cart_array"],$i-1,1,array(array("item_id"=>$pid,"quantity"=>$each_item['quantity']+1)));