|
Posted by Derek Williams on 12/12/05 01:30
Not sure if I can give a good answer, but try doing a var_dump on
$_SESSION["Search Result"] and see what you get. I suspect that it is
null. If that's the case then track down where it is getting assigned.
It should look something like $_SESSION["SearchResult"] = $users.
Christopher Jordan 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
>
>
>
> ---------------------------------
> Yahoo! Shopping
> Find Great Deals on Holiday Gifts at Yahoo! Shopping
>
Navigation:
[Reply to this message]
|