Bluehost.com Web Hosting $6.95

Re: [PHP] Store array as Session Variable

This is a discussion on Re: [PHP] Store array as Session Variable within the PHP General forums, part of the PHP Programming Forums category; $details is an array (just like $company_name was). Try to view print_r($details); and see what you get. ---John Holmes... ----- ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-28-2003
Cpt John W. Holmes
 
Posts: n/a
Default Re: [PHP] Store array as Session Variable

$details is an array (just like $company_name was). Try to view
print_r($details); and see what you get.

---John Holmes...

----- Original Message -----
From: "Pushpinder Singh Garcha" <pgarcha@adelphia.net>
To: <php-general@lists.php.net>
Sent: Monday, July 28, 2003 3:18 PM
Subject: [php] Store array as Session Variable


hello All,

I am trying to store an array as a session variable.

while ($row = mysql_fetch_array($result))
{
if ( !is_array($company_name) ) $company_name = array();
array_push($company_name, $row['company']);

// try to register session variable
$_SESSION['link'] = $company_name;

}


Now when I try to access this session variable in another file...I am
getting a junk value.I am not sure if I am getting this right.

$details = $_SESSION['link'];
echo "LINK: ".$details."<br>";


Can some one fill me in on this. Appreciate it ! Thanks in advance.

--Pushpinder Singh

Reply With Quote
  #2 (permalink)  
Old 07-29-2003
Rob Adams
 
Posts: n/a
Default Re: [PHP] Store array as Session Variable


"Pushpinder Singh Garcha" <pgarcha@adelphia.net> wrote in message
news:E8A08D14-C131-11D7-8E7F-000393874598@adelphia.net...
> $details is empty !!
>


I'd check your sql query and see if any rows are being returned. Also, put
the initializing of the array ($company_name = array()) outside of your
loop, just in case.

I used to think that you had to serialize arrays before saving to session,
but apparently that's not the case. Good to know.

-- Rob



> Thanks
> --Pushpinder
>
>
> On Monday, July 28, 2003, at 03:31 PM, CPT John W. Holmes wrote:
>
> > $details is an array (just like $company_name was). Try to view
> > print_r($details); and see what you get.
> >
> > ---John Holmes...
> >
> > ----- Original Message -----
> > From: "Pushpinder Singh Garcha" <pgarcha@adelphia.net>
> > To: <php-general@lists.php.net>
> > Sent: Monday, July 28, 2003 3:18 PM
> > Subject: [php] Store array as Session Variable
> >
> >
> > hello All,
> >
> > I am trying to store an array as a session variable.
> >
> > while ($row = mysql_fetch_array($result))
> > {
> > if ( !is_array($company_name) ) $company_name = array();
> > array_push($company_name, $row['company']);
> >
> > // try to register session variable
> > $_SESSION['link'] = $company_name;
> >
> > }
> >
> >
> > Now when I try to access this session variable in another file...I am
> > getting a junk value.I am not sure if I am getting this right.
> >
> > $details = $_SESSION['link'];
> > echo "LINK: ".$details."<br>";
> >
> >
> > Can some one fill me in on this. Appreciate it ! Thanks in advance.
> >
> > --Pushpinder Singh
> >

>



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:04 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0