Page 1 of 1
Fatal error: Call to a member function on a non-object
Posted: Fri Apr 20, 2007 4:33 pm
by IXxAlnxXI
i get an error on like 386, which is the $db->Close();, i get that fatal error for everyting the database connection is closed, below the $db-Close(); is my function which closes the database (it's in a class). anyone know why i keep getting the fatal error? any help is appreciated, thanks
'Fatal error: Call to a member function on a non-object'
Code: Select all
function Close()
{
mysql_close( $this->db_link);
}
Posted: Fri Apr 20, 2007 8:16 pm
by volka
try
Code: Select all
echo 'db: '; var_dump($db);
$db->Close();
Posted: Fri Apr 20, 2007 10:55 pm
by IXxAlnxXI
that doesn't seem to work, but thanks for the help thoug.h i still can't get it ><. the headerflie has a class, which has 2 functions: Close() and Connect(), Connect() is called and works fine, but Close() is giving the error
Posted: Fri Apr 20, 2007 11:12 pm
by John Cartwright
The reason volka asked you to try that is to post the result back here, so we can be certain the object exists.
Posted: Fri Apr 20, 2007 11:20 pm
by IXxAlnxXI
oooh, alright, so i post the code and reply back the results, correct?
Posted: Fri Apr 20, 2007 11:22 pm
by IXxAlnxXI
after pasting volka's code, it shows this, the "db:bool(true)"
db: bool(true)
Fatal error: Call to a member function on a non-object in /home/.frumisera/danial/rtndev.roadtripnation.com/watch.php on line 386
Posted: Fri Apr 20, 2007 11:48 pm
by IXxAlnxXI
any suggestions?
Posted: Fri Apr 20, 2007 11:59 pm
by John Cartwright
Just so you know bumping prior to 24 hours since your last post is a violation of our rules.
Please take the time to read our
forum rules, so you don't violate our rules again

Posted: Sat Apr 21, 2007 12:02 am
by IXxAlnxXI
sorry about that :/ please don't consider this a bump, either, it's a public apology

Posted: Sat Apr 21, 2007 8:41 am
by volka
IXxAlnxXI wrote:db: bool(true)
Fatal error: Call to a member function on a non-object in /home/.frumisera/danial/rtndev.roadtripnation.com/watch.php on line 386
$db is not an object but a boolean, like $db = true;
Posted: Sat Apr 21, 2007 9:09 am
by aaronhall
Post the code where $db is being assigned. Is Close() a method of a class, or is it just a user-defined function?
Posted: Sat Apr 21, 2007 10:19 am
by neel_basu
Case 1 : You are trying to close the connection after the class has been destructed.
Case 2: The MySQL connection has been closed by some other functions or classes.
EDIT
-------------------------------

Yes I've made this post without CAPS everywhere.
Posted: Sat Apr 21, 2007 12:46 pm
by volka
neel_basu, please note that a var_dump of the variable in question returned bool(true), it's not an object.
Posted: Sat Apr 21, 2007 12:52 pm
by neel_basu
Oh! Sorry I've overlooked db: bool(true)