Saturday 15 August 2015

php - Can't figure out the following error -



php - Can't figure out the following error -

parse error: syntax error, unexpected ';' in c:\xampp\htdocs\cart\admin\addtocart.php on line 13

here code,

<?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"] $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(); } ?>

you have missed lastly closing brace ')' on below line

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

php mysql

No comments:

Post a Comment