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

Posts: 3
Name: Joe
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
Reply With Quote
View Public Profile
 
Old 04-30-2008, 01:16 PM Re: Fatal error: Using $this when not in object context
VirtuosiMedia's Avatar
Webmaster Talker

Posts: 683
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
Reply With Quote
View Public Profile Visit VirtuosiMedia's homepage!
 
Old 05-17-2008, 11:55 AM Re: Fatal error: Using $this when not in object context
Junior Talker

Posts: 1
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
Reply With Quote
View Public Profile
 
Old 05-17-2008, 12:43 PM Re: Fatal error: Using $this when not in object context
NullPointer's Avatar
Will Code for Food

Posts: 482
Name: Matt
Location: Irvine, CA
$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.
__________________
http://tinsology.com/ - Under construction

Last edited by NullPointer : 05-17-2008 at 12:48 PM.
NullPointer is online now
Reply With Quote
View Public Profile
 
Reply     « Reply to Fatal error: Using $this when not in object context

Thread Tools

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

vB 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.12261 seconds with 12 queries