RE: [PHP] session variables - help
| From: | Ford, Mike | Date: | Fri, 14 Aug 2009 12:47:16 +0000 |
| Subject: | RE: [PHP] session variables - help | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-296789@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Ford, Mike [mailto:M.Ford@leedsmet.ac.uk]
> Sent: 14 August 2009 11:45
> > Now, here is the update_order.php code in entirety:
> >
> > [code]
> >
> > <?php
> > session_start();
> > foreach ($_SESSION as $var => $val) {
> > if ($val == "0") {
> > unset($_SESSION[$var]);
> > } elseif ($val == '') {
> > unset($_SESSION[$var]);
> > } else {
> > $val = $_SESSION[$var];
>
> That line is back-to-front -- you're assigning the current value in
> the session to $val, which is then immediately thrown away as the
> foreach loop starts a new iteration. What you mean is
> $_SESSION[$var] = $val.
No, wait a minute, hold your foot up! I was so focussed on the strange assignment that I
didn't read the whole thing properly. What you're *actually* doing here is -- er, well,
totally not what you want to, I suspect! Having re-read the message I responded to, I'm going
to go back to it and post another response....
Cheers!
Mike
--
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,
Leeds Metropolitan University, C507, Civic Quarter Campus,
Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 812 4730
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm