PHP: Call to a member function GetUserCollection() on a non-object
<p>Apologies for posting this question - I know they have been asked and answered several times (i.e. <a href="http://stackoverflow.com/questions/1787561/call-to-a-member-function-on-a-non-object">Call to a member function on a non-object</a>, etc), but non of the suggested solutions seem to work for me. This is what I have:</p>

<pre><code>class Common {

    private $model;

    public function _construct() {
        $this-&gt;model = Model::GetInstance();
        //$this-&gt;model-&gt;GetUserCollection();
    }

    public function validateusername($username) {
        $userlist = $this-&gt;model-&gt;GetUserCollection();
        $result = true;

        if ($username == false) {
            $this-&gt;error = "Please enter username.";
            $result = false;
        }
    }

}

// This is my DB model

class Model {

    private static $instance = null;
    private $conn = false;

    private function __construct() {
        if (!$this-&gt;connect()) {
            print "Unable to connect to database!";
            exit;
        }
    }

    public function connect() {
        if ($this-&gt;conn == false) {
            $this-&gt;conn = mysql_connect(DBHOST, DBUSER, DBPASS);

            if ($this-&gt;conn) {
                if (!mysql_select_db(DBNAME, $this-&gt;conn)) {
                    print "DB Connection Error!";
                    exit;
                }
            }
        }
        return $this-&gt;conn;
    }

    public function GetUserCollection() {
        return UserCollection::GetInstance();
        // return new UserCollection();
    }

    public static function GetInstance() {
        if (!self::$instance) {
            self::$instance = new Model();
        }
        return self::$instance;
    }
}
</code></pre>

<p>Why is it exactly this line : <strong>$userlist = $this->model->GetUserCollection();</strong> which is throwing me an error even though I am returning a new instance of it in the in the model Thanks in advance, JJ.</p>
