php error
PHP Fatal error: Call to a member function query() on a non-object
i have attached the code. What could be causing this issue. it works find in php4 but when i change to 5 i get that error
if(!defined('SITE_PATH')) die('Hacking attempt');
function pear_session_open($save_path, $name)
{
return true;
}
function pear_session_close()
{
return true;
}
function pear_session_read($session_id)
{
global $db;
$sql = "SELECT data FROM " . TBL_SESSION . " WHERE session_id = '"
. addslashes($session_id) . "'";
return $db->one_data($sql);
}
function pear_session_write($session_id, $data)
{
global $db;
$expires = HW_TIME + get_cfg_var("session.gc_maxlifetime");
$sql = "REPLACE INTO " . TBL_SESSION . "(session_id, expires, data) "
. "VALUES('" . addslashes($session_id) . "', $expires, '" . addslashes($data)
. "')";
$db->query($sql);
return true;
}
function pear_session_destroy($session_id)
{
global $db;
$sql = "DELETE FROM " . TBL_SESSION . " WHERE session_id = '"
. addslashes($session_id) . "'";
$db->query($sql);
return true;
}
function pear_session_gc($gc_maxlifetime)
{
global $db;
$db->query("DELETE FROM " . TBL_SESSION . ' WHERE expires < '.HW_TIME);
// $db->query('OPTIMIZE TABLE '.TBL_SESSION);
return true;
}
session_set_save_handler(
"pear_session_open",
"pear_session_close",
"pear_session_read",
"pear_session_write",
"pear_session_destroy",
"pear_session_gc");
"Jamroom is a Profile Centric CMS system suitable as a development framework for building entire communities. Highly modular in concept. Suitable for enterprise level development teams or solo freelancers."