Page 1 of 1

$this-> Bugs me

Posted: Fri Oct 08, 2010 2:02 pm
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

Re: $this-> Bugs me

Posted: Fri Oct 08, 2010 2:08 pm
by s.dot
What PHP version is on your new server?

Code: Select all

<?php

echo PHP_VERSION;

?>

Re: $this-> Bugs me

Posted: Fri Oct 08, 2010 2:12 pm
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?

Re: $this-> Bugs me

Posted: Fri Oct 08, 2010 2:13 pm
by s.dot
It is object notation which PHP5 supports.

Re: $this-> Bugs me

Posted: Fri Oct 08, 2010 2:14 pm
by s.dot
What are the errors you are receiving?

Re: $this-> Bugs me

Posted: Fri Oct 08, 2010 2:25 pm
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

Re: $this-> Bugs me

Posted: Fri Oct 08, 2010 2:27 pm
by s.dot
Post your code from lines ~10 - ~30

Re: $this-> Bugs me

Posted: Fri Oct 08, 2010 2:41 pm
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

Re: $this-> Bugs me

Posted: Fri Oct 08, 2010 2:48 pm
by John Cartwright
In that function, rename $this to anything else. "$this" is reserved for class scope.

Re: $this-> Bugs me

Posted: Fri Oct 08, 2010 3:03 pm
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

Re: $this-> Bugs me

Posted: Fri Oct 08, 2010 3:22 pm
by John Cartwright
I said all instances of $this :wink:

Hint.. function parameters.

Re: $this-> Bugs me

Posted: Fri Oct 08, 2010 3:52 pm
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

Re: $this-> Bugs me

Posted: Fri Oct 08, 2010 4:44 pm
by gotornot
sorry guys taht works just other problems now i hate it whe 2 servers are not exactly configuired the same

Re: $this-> Bugs me

Posted: Fri Oct 08, 2010 7:51 pm
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.