Hi people,

As I understand it, object are unserialized into their former Class, if 
that Class is in memory. That's right, right?

Well, consider the following code:

        include_once("../config.inc.php");
        include_once($WORKDIR."obj/foto.obj.php");
        if($type == 1)
        {
                $foto = new Foto();
        }
        if(isset($_SESSION['foto']))
        {
                $foto = unserialize($_SESSION['foto']);
        }
        $foto->makeInputFoto($type);
        $_SESSION['foto']=serialize($foto);

It's for a page that can edit or add a foto in(to) the database. If I run 
it like this, with ?type=1 in the URL, it works the first time, but after a 
reload of the exact same page, I get a 'Call to a member function on a 
non-object' in the line '$foto->makeInputFoto($type);'. Why is that? It's 
already a Foto-object, because I unserialized it, isn't it?

I also tried:
        if($type == 1 && !isset($_SESSION['foto']))
        {
                $foto = new Foto();
        }
        elseif(isset($_SESSION['foto']))
        {
                $foto = unserialize($_SESSION['foto']);
        }
With exactly the same effect. Any idea on how I can solve this? Tia!

-- 
Kind regards,
Tim

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

Reply via email to