Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Fatal error using $this
Old 08-17-2008, 02:01 PM Fatal error using $this
Junior Talker

Posts: 4
Name: Josh Mangel
Trades: 0
Fatal error: Using $this when not in object context in /home/whowould/public_html/database.php on line 28

Error in script:

// End of Edit
$this->link = mysql_connect($hostname, $username, $password);
mysql_select_db($dbname);

?>

What should I use as the reserved variable as a replacement of $this.

Last edited by josh2bmd; 08-19-2008 at 11:07 PM..
josh2bmd is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-17-2008, 05:10 PM Re: Fatal error using $this
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
Unless you inside a class, you cannot use $this as it's a reserved variable.

Also, take a look at:
http://uk2.php.net/manual/en/language.oop5.php
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 08-17-2008, 06:21 PM Re: Fatal error using $this
Junior Talker

Posts: 4
Name: Josh Mangel
Trades: 0
What can I use for the reserved variable then?
josh2bmd is offline
Reply With Quote
View Public Profile
 
Old 08-17-2008, 06:45 PM Re: Fatal error using $this
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Any object with a public field named "link", or with a setter method for "link".
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 08-18-2008, 02:51 PM Re: Fatal error using $this
Junior Talker

Posts: 4
Name: Josh Mangel
Trades: 0
alright fixed it... thanks guys.
josh2bmd is offline
Reply With Quote
View Public Profile
 
Old 08-19-2008, 11:04 PM Re: Fatal error using $this
Junior Talker

Posts: 4
Name: Josh Mangel
Trades: 0
VERY simple fix haha

// End of Edit
//$this->
link = mysql_connect($hostname, $username, $password);
mysql_select_db($dbname);



?>

... didnt even have to replace $this as the reserved variable.
josh2bmd is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Fatal error using $this
 

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