Hi. I am new both in daniweb and as a web programmer (university student) and I'd really like some help, if possible, with a shopping cart I've been developing for a lesson/project of mine. The error I get is: Parse error: syntax error, unexpected '{' in C:\Apache_PHP_MySQL\xampp\htdocs\site\basket.php on line 135. I've checked my code again and again and i can't find any errors around the line mentioned. The code follows. I know it might be a bit chaotic but I am still trying to find my style :P. Any help would be appreciated. (the language that you might not understand is greek, though I don't think you will need it)

<?php
  session_start();
  if($action=="deleteall")
  {
    unset($_SESSION["basket"]);
  }
  else  
  {
    $basket=$_SESSION["basket"];
    $action=$_GET["action"];
    $total=0;
    switch ($action)
    {
      case "add":
	    if ($basket)
	    {
	      $basket.=",".$_GET["prodid"];
        } 
	    else
	    {
		  $basket=$_GET["prodid"];
	    }
	    break;
	  case "delete":
	    if($basket)
	    {
          $items=explode(",",$basket);
	      $newbasket="";
		  foreach($items as $item)
		  {
		    if ($_GET["prodid"]!=$item) 
		    {
			  if ($newbasket!="")
			  {
			    $newbasket.=",".$item;
			  }
			  else
			  {
			    $newbasket=$item;
			  }
		    }
		  }
	    $basket=$newbasket;
	    }
	    break;
	  case "update":
	    if($basket) 
	    {
		  $newbasket="";
		  foreach($_POST as $key=>$value)
		  {
		    if(stristr($key,"qty"))
		    {
		      $id=str_replace("qty","",$key);
			  $items=($newbasket!="")?explode(",",$newbasket):explode(",",$basket);
			  $newbasket="";
			  foreach ($items as $item)
			  {
			    if ($id!=$item)
			    {
			      if ($newbasket!="")
				  {
				    $newbasket.=",".$item;
				  }
				  else
				  {
				    $newbasket=$item;
				  }
			    }
			  }
			  for ($i=1;$i<=$value;$i++)
			  {
			    if ($newbasket!="")
			    {
			      $newbasket.=",".$id;
			    }
			    else
			    {
			      $newbasket=$id;
			    }
			  }
		    }
		  }
	    }//end of [if($basket)] 
	    $basket=$newbasket;
	    break;
    }//end of [switch]
    $_SESSION["basket"]=$basket;
  }//end of [else]
?>
<html>
<head>
<title>DNZ e-PCshop</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
body,td,th {
	font-family: Trebuchet MS, Arial, Helvetica, sans-serif;
}
-->
</style>
</head>
<body background="/gfx/main.jpg">
<?php
  $con=mysql_connect("localhost","root","");
  if(!$con)
  {
    die('Could not connect: '.mysql_error());
  }
  mysql_select_db("epcshop",$con);
  if($basket)
  { 
    $items=explode(",",$basket);
    $contents=array();
	foreach($items as $item)
	{
	  $contents[$item]=(isset($contents[$item]))?$contents[$item]+1:1;
	}
?>
<form action="basket.php?action=update" method="post" id="cart">
<table border="0" align="center" width="95%" vspace="50">
<caption align="center"><b>ΚΑΛΑΘΙ ΑΓΟΡΩΝ</b></caption>
  <tr bgcolor="#FF9933">
    <td align="center" width="20%"><b>ΚΑΤΗΓΟΡΙΑ</b></td>
    <td align="center" width="57%"><b>ΤΙΤΛΟΣ</b></td>
    <td align="center" width="5%"><b>ΤΙΜΗ</b></td>
    <td align="center" width="8%"><b>ΠΟΣΟΤΗΤΑ</b></td>
    <td align="center" width="10%"><b>ΣΥΝΟΛΟ</b></td>
  </tr>
<?php
    foreach ($contents as $id=>$qty)
    {
	  $result=mysql_query("SELECT * FROM products WHERE id_product='".$id."'",$con);
	  while($row=mysql_fetch_array($result))
	  {
	    $recat=mysql_query("SELECT * FROM categories WHERE id_category='".$row['category']."'",$con);
	    while($rowcat=mysql_fetch_array($recat))
	    {
?>
  <tr bgcolor="#FFFF99">
    <td align="center" width="20%"><?php echo $rowcat['category']; ?></td>
    <td align="center" width="57%"><?php echo "(".$id.") ".$row['name']; ?></td>
    <td align="center" width="5%"><?php echo $row['price']."&euro;"; ?></td>
    <td align="center" width="8%"><?php echo "<input type='text' name='qty".$id."' value='".$qty."' size='3' maxlength='3'>"; ?></td>
    <td align="center" width="10%">
	<?php 
	echo ($row['price']*$qty)."&euro;<br><a href='basket.php?action=delete&id='".$id.">Διαγραφή</a>";
	$total+=$row['price']*$qty; 
	?>
    </td>
  </tr>
<?php
	    }
	  }
    }
?>
  <tr bgcolor="#999999">
    <td align="right" colspan="4">Αξία προϊόντων:</td>
    <td align="center" width="10%"><?php echo $total."&euro;<br><a href='basket.php?action=deleteall'>Διαγραφή όλων</a>"; ?></td>
  </tr>
  <tr bgcolor="#999999">
    <td align="right" colspan="5">
      <button type="submit">Ανανέωση</button><br>
      <b>Σημείωση:</b> Πατήστε το κουμπί "Ανανέωση" για να δείτε τις νέες τιμές αν έχετε αλλάξει την ποσότητα!!!
    </td>
  </tr>
  <tr bgcolor="#999999">
    <td align="center" colspan="5"><a href="order_form.php">ΣΥΜΠΛΗΡΩΣΗ ΦΟΡΜΑΣ ΠΑΡΑΓΓΕΛΙΑΣ</a></td>
  </tr>
</table>
</form>
<?php
  }//end of [if($basket)]
  else
  {
?>
    <table align="center" width="95%">
      <tr bgcolor="#999999">
        <td align="center">Δεν υπάρχουν προϊόντα στο καλάθι σας.</td>
	  </tr>
    </table>
<?php
  }
  mysql_close($con);
?>
</body>
</html>

Sorry guys my mistake the code works... there was a ")" missing. I fixed it. Do whatever you like with it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.