Jump to content

Archived

This topic is now archived and is closed to further replies.

appeland

__PHP_Incomplete_Class Object *gargel*

Recommended Posts

Hello,
this problem is described in a lot of forums and other articels
on the net already but I still cant make it work:

I am trying to put a class into a session so that I dont have to
include it again and again (it's a DB Access Class).

[b]Here is what I do on page one:[/b]
[code]
<?
include('database.php');
session_start();
header("Cache-control: private"); //IE 6 Fix
$_SESSION ['database'] = new database;


$database = &New database;
$query="SELECT name FROM users where id = 63";
$database->setQuery($query);
$row=$database->loadObjectList();
$row=$row[0];
?>
<a href ="http://testserver/test/test2.php">Show <? echo $row->name;?>'s username</a>
[/code]

-> this works fine and the result is delivered from the DB.
[b]
The link in there brings me to the next page which looks like this:[/b]
[code]
<?
session_start();
header("Cache-control: private"); //IE 6 Fix
echo "Session: <pre>";
print_r($_SESSION);
echo "</pre><br><br>";

$query="SELECT username FROM users where id = 63";
$database->setQuery($query);
$row=$database->loadObjectList();
$row=$row[0];
echo $row->username;
?>
[/code]

As you can see I am looking into the session to see what's in it
but I keep getting:

[b][database] => __PHP_Incomplete_Class Object.[/b]

All the topics I found somewhere else just say that I need to include the class file before
I start the session, but I do that already [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /]

I know this is trivial but I just cant get the hang of it.
Your help is highly appreciated.
Thanks & Regards,
Andi

Share this post


Link to post
Share on other sites
Try this approach
[code]
<?php
               session_start();

        if (isset($_SESSION['myobjectname'])) {
            $myobjectname= unserialize($_SESSION['myobjectname']);
        }
        else {     
            $myobjectname= new myobjectname();
        }

           // processing

          // resave  
          $_SESSION['myobjectname'] = serialize ($myobjectname);
?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.