i received this error while loading this page. the error is like this, Parse error: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) in /server/disk_1/websites/makemyrice/cart_update.php on line 7 the line number 7 is "if(isset($_COOKIE['cards']))"
<?php
class CartUpdate
{
if(isset($_COOKIE['cards']))
{
$cookie = $_COOKIE['cards'];
$cookie = stripslashes($cookie);
$savedCardArray = json_decode($cookie, true);
$variety=$savedCardArray['CART'][0];
$quantity=$savedCardArray['CART'][1];
$bran=$savedCardArray['CART'][2];
}
setcookie('total', $total);
}
function __construct()
{
}
function add()
{
$variety = test_input($_POST["variety"]);
$rice_type = test_input($_POST["rice_type"]);
$quantity = test_input($_POST["quantity"]);
$bran = test_input($_POST["bran"]);
$items[]=array($variety,$quantity,$bran,$rice_type);
$json = json_encode($items);
setcookie('cards', $json);
print_r($items);
}
function delete()
{
setcookie( 'cards', "", time()-3600);
header('location:cart.php');
}
function cartlen()
{
}
?>