Jump to content
Larry Ullman's Book Forums

robert1962

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by robert1962

  1. Hi. I'm having a problem with the code in checkout.php in Chapter 19.

    For some reason, I get the following errors:

     

    Notice: Undefined index: cart in C:\xampp\htdocs\php\PHPandMySQL\ch19\checkout.php on line 26.

     

    Warning: Invalid argument supplied for foreach() in C;\xampp\htdocs\php\PHPandMySQL\ch19\checkout.php on line 26.

     

    Notice: Undefined index: cart in C;\xampp\htdocs\php\PHPandMySQL\ch19\checkout.php on line 37.

     

    I have included the header.html file. This starts the session. So the session variable is set. Here is my code for the foreach function on line 26:

     

    foreach($_SESSION['cart'] as $pid => $item) {

    ...

    }

     

    Here is the if conditional for line 37:

     

    if($affected == count($_SESSION['cart'])) {

    ...

    }

     

    Why am I getting these notices and warnings? The code appears correct.

×
×
  • Create New...