Call to a member function … on a non-object

This error usually means that either your code is expecting a variable that isn’t there (so for instance your database needs populating) or your code has assigned the variable in such a way that it can’t be picked up correctly.

You can’t simply ‘echo’ the object variable to see what has been assigned however by using echo in combination with print_r you can view both the variables that your code is expecting as well as those that are actually assigned.

Syntax:

echo print_r($object);

Replace $object with the name of the object in question.

Leave a Reply

Your email address will not be published. Required fields are marked *

* Copy This Password *

* Type Or Paste Password Here *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© dougandrews.co.uk
CyberChimps