I am in a class as well as a constructor.

class DBI
{
        //var declarations
        function DBI() 
        {
                $retVal = true;
                
$this->setDBConn(mysql_connect('localhost',$this->_dbuser,$this->_dbpwd));
                if ($this->getDBConn() == false)
                        $retVal = false;
                if(mysql_select_db($this->getDBName(),$this->getDBConn())==false)
                        $retVal = false;
                return $retVal;
        }
        //more functions...     
}

I even tried removing $this->_dbuser and $this->_dbpwd and replacing
them with hardcoded data, and the error persists.

On Thu, 2003-08-21 at 19:19, DvDmanDT wrote:
> Has with classes to do... The error claims that code isn't in a class which
> makes it invalid as $this is the current class... If you aren't in a class
> then there's no $this... however, if you are in a class, you just found a
> bug or a typo in your script...
> 
> -- 
> // DvDmanDT
> MSN: [EMAIL PROTECTED]
> Mail: [EMAIL PROTECTED]
> "Jonathan Villa" <[EMAIL PROTECTED]> skrev i meddelandet
> news:[EMAIL PROTECTED]
> > First of all, let me say that I am using PHP 5, but not including any
> > new php5 features, just installed it.
> >
> > Anyway,
> >
> > this is the offending code..
> >
> > $retVal = true;
> > $this->setDBConn(mysql_connect('localhost',$this->_dbuser,$this->_dbpwd));
> > if ($this->getDBConn() == false)
> > $retVal = false;
> >
> > and on my page I get the following error:
> >
> > Fatal error: Using $this when not in object context in /var/www/xxxxx
> >
> > Now this is code I've used time and time before...also, I have never
> > seen an error such as the above.
> >
> > Any ideas?
> >
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to