title: PHP undefined index
body: <p>Heya I get this error message. I've been looking everywhere but I dont know how to fix it? Im a beginner so I'm really confued. Thanks in advance</p>
  
  <p>Notice: Undefined index: cart in /nas/students/j/j39-green/unix/public_html/ISD5/inc/functions.inc.php on line 3</p>
  
  <p>You have no items in your shopping cart</p>
  
  <pre><code>&lt;?php
  function writeShoppingCart() {
  $cart = $_SESSION['cart'];
  if (!$cart) {
      return '&lt;p&gt;You have no items in your shopping cart&lt;/p&gt;';
  } else {
      // Parse the cart session variable
      $items = explode(',',$cart);
      $s = (count($items) &gt; 1) ? 's':'';
      return '&lt;p&gt;You have &lt;a href="cart.php"&gt;'.count($items).' item'.$s.'  in your shopping cart&lt;/a&gt;&lt;/p&gt;';
  }
  }
  </code></pre>