Closed Thread
Fatal error: Using $this when not in object context
Old 04-30-2008, 01:18 PM Re: Fatal error: Using $this when not in object context
Junior Talker

Posts: 3
Name: Joe
Trades: 0
it wasnt. It was just a call to a class and I forgot to annotate accoudingly. Im still haing trouble though. I could probaly stop bohering you if there was a resource where I could see the functions of Mysql and their postgresql counterparts. this is what Im getting

Code:
Warning:  pg_query(): supplied argument is not a valid PostgreSQL link resource in /berw/ugrad1/base/j/jpc7/public_html/test2/class.php on line 56
and the code itself

Code:
function query($sql) {
        if (!$queryResource=pg_query($sql,$this->dbConn))
            trigger_error ('Query failed: '.pg_error($this->dbConn).
                           ' SQL: '.$sql);
        return new PostgreSQLResult($this,$queryResource);
    }
Jezarel is offline
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 04-30-2008, 02:16 PM Re: Fatal error: Using $this when not in object context
VirtuosiMedia's Avatar
Usability > SEO

Posts: 1,010
Trades: 0
If you're looking for just a function comparison, try this.

If you're not too far in your development, I'd highly recommend using the PDO drivers on that other link I gave you.
VirtuosiMedia is offline
View Public Profile Visit VirtuosiMedia's homepage!
 
Old 05-17-2008, 12:55 PM Re: Fatal error: Using $this when not in object context
Junior Talker

Posts: 1
Trades: 0
Hello i got the same problem...

Fatal error: Using $this when not in object context in /home/.backbones/user/mydomain.com/config.inc.php on line 5

this is the script config.inc.php

PHP Code:
<?php


/*** Basic Site Variables (required) ***/
$this->siteurl="http://www.yourdomain.com"// location of countercode software (without trailing slash).
$this->sitename="YourSite.com"// the name of the counter site
$this->adminpassword="password"// the admin password
$this->your_email='you@yourdomain.com'// define the admin's email address.

$this->language="english"//the language used for the user interface

/*** MYSQL Config (required) ***/
$host "localhost"// MYSQL host
$data "database"// Mysql database name
$user "username"// Mysql username
$pass "password"// Mysql password
koncling is offline
View Public Profile
 
Old 05-17-2008, 01:43 PM Re: Fatal error: Using $this when not in object context
NullPointer's Avatar
Will Code for Food

Latest Blog Post:
Easy PHP Search with Opera
Posts: 1,066
Name: Matt
Location: Irvine, CA
Trades: 0
$this has no meaning outside of an object. You should only use $this and the -> operator when working with objects. -> is used for accessing the methods of an object and $this is used when an object needs to refer to itself. In this case there is no object at all so $this does not exist.

Here's an example of when you should use $this and ->
PHP Code:
class myObject
{
     private 
$myVar;

     function 
myFunc()
     {
          
$this->myVar 'hello world';
     }


In this case you don't have to use $this, but it works either way. Most of the time when I use $this is when I'm hiding a variable (ie if myFunc to a variable called $myVar as input), but there are other contexts where it is useful as well.

By the way, is there a term for the -> operator? I usually just call it the arrow operator.
__________________
Tinsology | How to Post Code | EverythingDev

Last edited by NullPointer; 05-17-2008 at 01:48 PM..
NullPointer is offline
View Public Profile
 
Closed Thread     « Reply to Fatal error: Using $this when not in object context

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.11962 seconds with 12 queries