Re: =sessions / J. Meloni Textbook=
| From: | Burhan Khalid | Date: | Tue, 18 Nov 2003 19:31:54 +0000 |
| Subject: | Re: =sessions / J. Meloni Textbook= | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170143@lists.php.net to get a copy of this message | ||
Anthony Ritter wrote:
Using mysql, apache and win98 The following code is from "PHP, mySQL and Apache" (SAMS) by Julie Meloni. Page 338-339 (hour 16). After choosing my selections in the form box and hitting submit I get: ............... Warning: Invalid argument supplied for foreach() in c:\apache\htdocs\listing16.5.php on line 13 ..................[ snip ]
// script 16.5.php <html> <head> <title>Listing 16.5 Accessing session variables</title> </head> <body> <h1> Content Page</h1> <?php if (isset($_SESSION[products])) { print "<b>Your cart:</b><ol>\n"; foreach (unserialize($_SESSION[products]) as $p) {you are missing session_start(); on 16.5 You need that in order to populate the $_SESSION array. -- Burhan Khalid phplist[at]meidomus[dot]com http://www.meidomus.com ----------------------- "Documentation is like sex: when it is good, it is very, very good; and when it is bad, it is better than nothing."print "<li>$p";} print "</ol>"; } ?> <a href="listing16.4.php">Back to product choice page</a> </body> </html>