On 2 Mar 2012, at 20:07, Jim Giner wrote: > 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']; > } What is the type of $e (i.e. what's the class called)? Side note... it looks like GetAnEntry fetches the entry into internal data. This isn't really how objects are supposed to work. To be more OO-like you should be passing the recordkey and Eventcode values into the constructor. But that's not relevant to your issue. > 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?? In the above script, the one that gets the objects out of the session, has the class been declared? IOW, have you included the PHP file that defines that class? If not then it won't be able to recreate the object. If that was the problem then I suggest you make sure you have error_reporting set to at least E_ALL, and display_errors set on, because this issue will be causing a fatal error, the text of which would make it obvious what's going wrong. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php