Page 1 of 1

Fatal error: Using $this when not in object context...

Posted: Tue Apr 01, 2008 1:50 pm
by glennn.php
a real estate cms (that's probably old) is returning this error:

Fatal error: Using $this when not in object context in /path/to/html/remgmt/admin/pb_events.php on line 29

Code: Select all

 
function DoEvents($this) {
    global $_CONF , $_TSM;
 
    $_TSM["MENU"] = "";
 
    //checking if user is logged in
    if (!$_SESSION["minibase"]["user"]) {
 
        if ($_SERVER["REQUEST_METHOD"] == "POST") {
 
            //autentificate
            $user = $this->db->QFetchArray("select * from {$this->tables[users]} where `user_login` = '{$_POST[user]}' AND `user_password` = '{$_POST[pass]}'");
 
            if (is_array($user)) {
                $_SESSION["minibase"]["user"] = 1;
                $_SESSION["minibase"]["raw"] = $user;
 
                //redirecing to viuw sites
                header("Location: $_CONF[default_location]");
                exit;
            } else
                return $this->templates["login"]->blocks["Login"]->output;
 
        } else
 
        /* LINE 29 >>> */   return $this->templates["login"]->blocks["Login"]->output;
 
    }
    if ($_SESSION["minibase"]["raw"]["user_level"] == 0) {
        $_TSM["MENU"] = $this->templates["login"]->blocks["MenuAdmin"]->output;
    } else {
        $_TSM["MENU"] = $this->templates["login"]->blocks["MenuUser"]->output;
    }
 
    if (!$_POST["task_user"])
        $_POST["task_user"] = $_SESSION["minibase"]["user"];
 
    if($_SESSION["minibase"]["raw"]["user_level"] == 1) {
        $_CONF["forms"]["adminpath"] = $_CONF["forms"]["userpath"];
    }
 
I'm pretty sure i've got PHP5 (on godaddy's server)...

anything anyone can help me with?

Thanks Much,
GN

Re: Fatal error: Using $this when not in object context...

Posted: Tue Apr 01, 2008 2:39 pm
by Christopher
It that function a method in a class or a standalone function. The variable name $this is reserved as the name used inside object to reference themselves. It is a parameter, so you should remove/rename the parameter if it is a method, or rename the parameter if it is a function.