Jump to content
Larry Ullman's Book Forums

Recommended Posts

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...