Fatal error when calling DB in function

From: Date: Wed, 05 Dec 2007 04:59:50 +0000
Subject: Fatal error when calling DB in function
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-28265@lists.php.net to get a copy of this message
Hi everyone, I have a bit of code which to me, looks like it should work, but is not and I am not sure why. Maybe someone here could help me. If I process this query outside of a function it works just fine. If I call it using a function as show below I get the error: Fatal error: Call to a member function on a non-object in /Library/WebServer/... <?php require_once("include/dbConnect.inc.php"); function getProps() { $res = $db->query('SELECT * FROM properties'); while ($res->fetchInto($prop)) { echo $prop->id . "<br />"; } $res->free(); } getProps(); ?>

« previous php.pear.general (#28265) next »