Welcome to the OzoneAsylum FaqWiki
Frequently Asked Questions
Server Side Coding
PHP

What is the cause of the error 'Call to a member function on a non-object'? Pages that link to <a href="https://ozoneasylum.com/backlink?for=5733" title="Pages that link to What is the cause of the error &amp;#039;Call to a member function on a non-object&amp;#039;?" rel="nofollow" >What is the cause of the error &#039;Call to a member function on a non-object&#039;?\

It usually occurs when you are hacking a script or joining 2 scripts together. It basically means one of 2 things:

1. Clash of naming conventions. (meaning some code clobbered the variable you're trying to call as an object)
2. Object not being instanciated. (meaning you forgot to 'make' the object)
3. Calling -> on an variable that is not an object (because you misstyped the variables' name (use error_reporting(E_ALL) to fix that), or because you are using the wrong one)

DmS has supplied a little bit of script which will dump the variable data onto the page:

code:
print("<pre>");
print_r(&#91;b&#93;$variable&#91;/b&#93;);
print("</pre>");



This should help you spot if there is a clash of naming conventions otherwise you will have to pik through your script to identify where the problem with the object comes in.

----------------------------
Relevant links:

Error: Call to a member function on a non-object

______________________
Emperor

(Edited by Tyberius Prime on 04-15-2004 04:50)

« BackwardsOnwards »

Show Forum Drop Down Menu