$this-> Bugs me

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gotornot
Forum Commoner
Posts: 54
Joined: Fri Jul 31, 2009 2:30 am

$this-> Bugs me

Post by gotornot »

I have a lot of these in my script that work on my old server but dont on my new one.

$this->

Is there a work around?

I dont have the money i used to so cant afford a scripter to help and i can do basic php but i dont know what they are and google isnt much help 8-(

Thanks
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: $this-> Bugs me

Post by s.dot »

What PHP version is on your new server?

Code: Select all

<?php

echo PHP_VERSION;

?>
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
gotornot
Forum Commoner
Posts: 54
Joined: Fri Jul 31, 2009 2:30 am

Re: $this-> Bugs me

Post by gotornot »

I think its the new PHP 5 which doesnt support the problem thats why its breaking and the server company wont change it :(

I just wondered if there was a work around for it?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: $this-> Bugs me

Post by s.dot »

It is object notation which PHP5 supports.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: $this-> Bugs me

Post by s.dot »

What are the errors you are receiving?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
gotornot
Forum Commoner
Posts: 54
Joined: Fri Jul 31, 2009 2:30 am

Re: $this-> Bugs me

Post by gotornot »

Fatal error: Using $this when not in object context in /home/q/u/quidfree/web/public_html/lib/emt-plugins/validatelink.php on line 19
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: $this-> Bugs me

Post by s.dot »

Post your code from lines ~10 - ~30
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
gotornot
Forum Commoner
Posts: 54
Joined: Fri Jul 31, 2009 2:30 am

Re: $this-> Bugs me

Post by gotornot »

Code: Select all

$GLOBALS['EMT_PLUGIN_DESCS']['validatelink'] = 'A link that a user clicks to validate their account';

	/**
	*
	*
	*/

function emt_validatelink_onload(&$this, $params = array())
{		// must add a tag with the same format that we will be using
	$this->add_tag('{checksum}');

	$linkBase = 'http://'.SITE_DOMAIN.'/activate.php?username={username}&check={checksum}';

	foreach ($params as $replace => $data)
	{
		if ($this->isHTML)
		{
			$text = isset($data['text']) ? $data['text'] : $linkBase;
			$link = '<a href="'.$linkBase.'" target=_blank>'.$text.'</a>';
		}
		else
Last edited by Benjamin on Fri Oct 08, 2010 2:53 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: $this-> Bugs me

Post by John Cartwright »

In that function, rename $this to anything else. "$this" is reserved for class scope.
gotornot
Forum Commoner
Posts: 54
Joined: Fri Jul 31, 2009 2:30 am

Re: $this-> Bugs me

Post by gotornot »

i did and now this has been shown to me

Fatal error: Call to a member function add_tag() on a non-object in /home/q/u/quidfree/web/public_html/lib/emt-plugins/validatelink.php on line 19

i replaced it with:

$GLOBALS['EMT_PLUGIN_DESCS']['validatelink'] = 'A link that a user clicks to validate their account';

/**
*
*
*/

function emt_validatelink_onload(&$this, $params = array())
{ // must add a tag with the same format that we will be using
$haveit->add_tag('{checksum}');

$linkBase = 'http://'.SITE_DOMAIN.'/activate.php?username={username}&check={checksum}';

foreach ($params as $replace => $data)
{
if ($haveit->isHTML)
{
$text = isset($data['text']) ? $data['text'] : $linkBase;
$link = '<a href="'.$linkBase.'" target=_blank>'.$text.'</a>';
}
else
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: $this-> Bugs me

Post by John Cartwright »

I said all instances of $this :wink:

Hint.. function parameters.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: $this-> Bugs me

Post by Jonah Bron »

John Cartwright wrote:I said all instances of $this :wink:

Hint.. function parameters.
It's no wonder sometimes people think we're mind readers :D
gotornot
Forum Commoner
Posts: 54
Joined: Fri Jul 31, 2009 2:30 am

Re: $this-> Bugs me

Post by gotornot »

sorry guys taht works just other problems now i hate it whe 2 servers are not exactly configuired the same
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: $this-> Bugs me

Post by s.dot »

gotornot wrote:sorry guys taht works just other problems now i hate it whe 2 servers are not exactly configuired the same
Try to be aware of practicing writing your code so that it will work on any server configuration! :) It's so much easier on you.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply