Forum Moderators: coopster
$size = count($_POST['Quantity']);
$_SESSION['id']=session_id();
$i = 0;
while ($i < $size) {
$cid= $_POST['Cartid'][$i];
$product= $_POST['ProductID'][$i];
$productname=$_POST['ProductName'][$i];
$quantity= $_POST['Quantity'][$i];
$Price= $_POST['Price'][$i];
$TotalPrice= $_POST['TotalPrice'][$i];
echo $productname;
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$query = "UPDATE cart SET Quantity ='$quantity', TotalPrice=$Price*$quantity where ProductID='$product' and CartID='$cid' ";
mysql_query($query);
if(!query)
echo "Query lesh";
$i++;
}
header("Location: view_cart.php");
exit;
Firstly change this :
$query = "UPDATE cart SET Quantity ='$quantity', TotalPrice=$Price*$quantity where ProductID='$product' and CartID='$cid' ;";
That is, a semi-colon after your query.
Then Change this :
mysql_query($query);
if(!query)
echo "Query lesh";
to :
if (!mysql_query($query)) {
echo mysql_error();
}
Find out the error in IE first.
And then we can go on further solving it.
ayush
if (!mysql_query($query)) {
echo mysql_error();
because i was not able to find what is happening
second: this is the error that i get
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*4 where ProductID='2'' at line 1You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*8 where ProductID='1'' at line 1
ans i don't know how to fix it