SESSION var and Objects problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



My first foray into classes & objects.

When retrieving a set of records, I'm using a class to build an object.  At 
this time I save each record/object into a Session array by doing this:

$rows = mysql_num_rows($qrslts);
 if ($rows > 0)
  for ($i=1;$i<=$rows;$i++)
  {
       $row = mysql_fetch_array($qrslts);
       $e = new Entry;
       if ($e->GetAnEntry($row['recordkey'],$row['Eventcode']))
       {
            $evts[] = $e;
            array_push($_SESSION['TMScurr_evts'],$e);     // THIS DOESN'T
            $cls_errs .= " Stored $e->event in sess var $i-1; ";   // THIS 
WORKS
       }
       else
            $cls_errs .= "Could not retrieve event record for 
".$row['recordkey']." ".$row['Eventcode'];
  }

The above code works AFAIK - the line above the array_push correctly stores 
my retreived record data  in the $evts array just fine and I can see the 
data when I use that array to display my page.
Note also that the var $cls_errs following the array_push does show me that 
valid values are being stored in $e
Later on, in my main process I attempt to retreive the contents of my 
Session var to use to re-display the data.  The code for that doesn't 
display any values.  In trying to debug this here is what I've done:

$cnt = count($_SESSION['TMScurr_evts']);
 echo "In Display  process with $cnt recs in session var TMScurr_evts. "; 
// THIS WORKS
 reset($_SESSION['TMScurr_evts']);
 $e = new Entry;
 for ($i=0;$i<count($_SESSION['TMScurr_evts']);$i++)
 {
      $e = array_pop($_SESSION['TMScurr_evts']);
      echo " in Display process - sess event $i is $e->event<br>";    // 
THIS DOESN'T
 }

This debugging code correctly tells me how many entries are in the Session 
array variable, but the attempt to echo the values stored in the first field 
of each object contained in it shows blank for each one.

What am I doing wrong when I try to pull the contents of my session array 
out and store them back into an Entry object, one at a time, so that I can 
display the object on my webpage?? 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux