Parse error: syntax error, unexpected T_ELSE
Posted: Sat Apr 16, 2011 2:05 pm
hi,i face some problem about T_ELSE..i dont know how to put them..
actually i want that if the product is already in the shopping cart,it will not insert into cart table,but if the product is not in the shopping cart,it will insert into shopping cart..so i use if else function..i have error in the code..
can anyone help me to solve them??thanks in advance..
actually i want that if the product is already in the shopping cart,it will not insert into cart table,but if the product is not in the shopping cart,it will insert into shopping cart..so i use if else function..i have error in the code..
can anyone help me to solve them??thanks in advance..
Code: Select all
<?php
session_start();
require_once 'config.php' ;
require_once 'application.php' ;
//var_dump($_FILES);
$id = $_SESSION['id'];
$username = $_SESSION['username'];
$pid=$_POST['pid'];
$pname=$_POST['pname'];
$uprice=$_POST['uprice'];
$quantity=$_POST['quantity'];
$query = "SELECT * FROM products WHERE pid = $pid";
$result = mysql_query($query);
$row=mysql_fetch_row($result);
$pid = $row[1];
$pname = $row[3];
$price = $row[5];
$promo = $row[6];
if ($promo != '0.00')
{ $uprice = $promo; }
else
{ $uprice = $price; }
$query1 = "SELECT * FROM register WHERE id =$id";
$result1 = mysql_query($query1);
$row1=mysql_fetch_row($result1);
if(isset($_SESSION['pid'])){
if(in_array($_POST['pid'],$_SESSION['pid'])){
header('Content-type:text/html;charset=utf-8');
echo"<script>alert(\"Your product is in your shopping cart!\")</script><script>window.location='home.php?id=$id'</script>";
}
}
$_SESSION['pid'][] = $_POST['pid'];
$_SESSION['pname'][] = $_POST['pname'];
$_SESSION['uprice'][] = $_POST['uprice'];
$_SESSION['quantity'][]=$_POST['quantity'];
else {
$result2 = mysql_query("INSERT INTO cart VALUES('','$id','$username','$pid','$pname','$uprice','$quantity')");
echo"<script>alert(\"Saved Successfully!\")</script><script>window.location='home.php?id=$id'</script>"; }
?>