2014-11-03 48 views
-2

解析错误:语法错误,意外';'在C:\ XAMPP \ htdocs中\车\ ADMIN \ addtocart.php上线13找不到以下错误

这里是我的代码,

<?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

你缺少a)在语句结尾 – Haris 2014-11-03 09:15:34

+0

你缺少a)在使用'array_splice'的语句末尾 – 2014-11-03 09:17:20

+0

请在运营商之间使用空格。阅读没有空格的代码是很痛苦的。有关如何格式化代码的指南,请参见[这里](http://docs.typo3.org/flow/TYPO3FlowDocumentation/stable/TheDefinitiveGuide/PartV/CodingGuideLines/PHP.html#php-code-formatting)。 – tyteen4a03 2014-11-03 09:17:32

回答

-1

你下面一行错过最后的右括号 ')'

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