Re: Store array as Session Variable
| From: | Chris Shiflett | Date: | Mon, 28 Jul 2003 19:27:21 +0000 |
| Subject: | Re: Store array as Session Variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-157226@lists.php.net to get a copy of this message | ||
--- Pushpinder Singh Garcha <pgarcha@adelphia.net> wrote:
> I am trying to store an array as a session variable.
Based on your code, it looked like your question had little to do with storing
an array as a session variable. To do that, this works:
$_SESSION['myarray'] = $myarray;
> while ($row = mysql_fetch_array($result))
> {
> if (!is_array($company_name))
> $company_name = array();
> array_push($company_name, $row['company']);
I cleaned up your formatting a bit, so that we can read your code more easily.
Can you explain what you intend to do here?
It looks to me like you expect $company_name to be populated during the "$row =
mysql_fetch_array($result)" part, since you check whether it is an array during
every iteration of the loop. Then, you are erasing its value unless it is an
array. Is this right so far? Is this what you want to do? I think this bit of
code is likely where your problem lies.
Chris
=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/