hi everyone,
keep getting this error although it shows the result perfectly..i cant do a $cart= ''; as it will show the incorrect result
Notice: Undefined variable: cart in D:\xampp\htdocs\book\includes\functions.inc.php on line 8
<?php
function writeShoppingCart() {
if(isset($_SESSION['cart']) ) {
$cart = $_SESSION['cart'];
}
if (!$cart) {
return '<p>You have no items in your shopping cart</p>';
} else {
// Parse the cart session variable
$items = explode(',',$cart);
$s = (count($items) > 1) ? 's':'';
return '<p>You have <a href="cart.php">'.count($items).' item'.$s.' in your shopping cart</a></p>';
}