On 12/11/05, Christopher Jordan <cscottjordan@xxxxxxxxx> wrote: > > Hi folks, > > I'm a ColdFusion developer, but I'm branching out into PHP because alot > of my smaller clients don't want to pay for CF. > > Anyway, a bit of background: > > I've got a page that does a search on one of my tables. I'm > using Justin Vincent's ezSQL (http://php.justinvincent.com) to fetch > the result set into an object that can be referenced nicely. Here's > what his example code looks like: > > // Select multiple records from the database and print them > out.. > $users = $db->get_results("SELECT name, email FROM users"); > foreach ( $users as $user ){ > // Access data using object syntax > echo $user->name; > echo $user->email; > } > > So far so good. So I've got an iframe on the page which (I hope) > will eventually display the results of the search. The user will then > click on the search result for which they want to view the details, and > the information from that row will be populated inside the main page > (the one that houses the iframe). > > Hope that makes sense. > > Okay, so my trouble is that I don't know how to enable the page > inside the iframe to have access to the result object created by > Justin Vincent's nifty little class. In CF I can just say: > > session.oResults = queryname > > CF automatically returns any query as an object with the name of > the query as the object name (i.e. queryname.MyIdField, or > queryname.EmployeeNumber, etc.) Using a line like the one > above (assigning the query object to a session variable) all of my > subsequent requests would have access to that result set simply by using > the object. > > I'm *sure* there's a way to do this in PHP. I'm just falling short of > finding the answer. I've tried: > > $_SESSION["SearchResult"] = $db->get_results($query); > > But it doesn't seem to work. I may have some other problem using the > object. I just re-read my error and it says: > > Fatal error: Call to a member function get_results() on a non-object in > inventorymanager.php on line 93 > > hmm... I sure would appreciate a little guidence here. Even if > my problem is with the way I'm using the object, is the idea of > assigning that object to the session scope the right way to do this or is > there a better approach. To that end, I suppose I'm looking for an idea of > the best practice. > > Thanks! > Christopher Jordan > Planet Access > Arlington, TX Fatal error: Call to a member function get_results() on a non-object in inventorymanager.php on line 93 This means what it says. When you call $db->get_results it is saying the class $db isn't set. If this is inside of your IFRAME and not the search page (or however you have this set up), make sure to get an instance of db before you call session_start(). Otherwise php will cry about having an object in the session with no name. If db->get_results returns an array then you can access your data like this: page 1: $_SESSION["SearchResult"] = $db->get_results("SELECT name, email FROM users"); page 2: foreach ($_SESSION["SearchResult"] as $user ){ I hope some of that helps or might point you in the right direction.