[Session-objects] Call to a member function on a non-object

From: Date: Fri, 16 Aug 2002 13:51:05 +0000
Subject: [Session-objects] Call to a member function on a non-object
Groups: php.general 
Request: Send a blank email to php-general+get-112959@lists.php.net to get a copy of this message
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

« previous php.general (#112959) next »