In the hierarchy of php developers, I am less than novice. I don't know squat about it. What I'm trying to do is install a module on my Joomla website for a Tweeter plug-in. When I enable the "mod" and display my page, I get:

Parse error: parse error, unexpected T_VARIABLE in /home/ [my website name]/public_html/joomla/modules/mod_tweetxt/helper.php on line 107

I had no idea what this meant, so I did my own research and discovered the problem has to do with a missing semi-colon. (Before asking help from others, I try to see if I can research and figure it out.) I counted down 107 lines and didn't see anything obvious; because I don't know what I'm looking for. Do you count the blank lines or just the lines of code? Either way, at 107 lines down, I see semi-colons. Obviously it must be missing somewhere around there. I tried comparing the IF logic elsewhere in the code to see if there is a pattern for entering the semi-colon. No luck figuring this out.

Could one of you folks help me find the error so I can fix this code so it will run? Here is the php code: (I hope that is the correct terminology. )

<?php 
/**
* TweetXT for Joomla!
* @Copyright ((c) 2009 joomlaxt.com
* @ All rights reserved
* @ Released under GNU/GPL License : [url]http://www.gnu.org/copyleft/gpl.html[/url]
* @ [url]http://www.joomlaxt.com[/url]
* @version 0.09.05
**/
defined('_JEXEC') or die('Direct Access to this location is not allowed.');
?>
<?php
class tweetXtHelper
{

function getLimit($params) {
	$uname = $params->get("twitterName","");    
	$count = $params->get("twitterCount",3);


	$url = "twitter.com";


	$req = "/account/rate_limit_status/".$uname.".json?count=".$count."";   

	$fp = fsockopen ($url, 80, $errno, $errstr, 30);
	if (!$fp || $errno) return $errstr;

    @fputs($fp, "GET ".$req." HTTP/1.1\r\n");
    @fputs($fp, "HOST: ".$url."\r\n");
    @fputs($fp, "Connection: close\r\n\r\n");
	// read the body data
	$res = '';
	$headerdone = false;
	while (!feof($fp)) {
		$line = fgets ($fp, 1024);
		if (strcmp($line, "\r\n") == 0) {
		// read the header
		$headerdone = true;
		}
		else if ($headerdone)
		{
			// header has been read. now read the contents
			$res .= $line;
		}
	}	
	fclose ($fp);

	$obj = json_decode($res);
	return $obj;

}


function getTweets($params)
{
	$uname = $params->get("twitterName","");    
	$count = $params->get("twitterCount",3);


	$url = "api.twitter.com";

// get 3 times the limit. That should ensure that the limit is reached even if there are some retweets (which will be filtered out by the API)
		$xCount = 3 * $count;

	$req = "/1/statuses/user_timeline/".$uname.".json?count=".$xCount."";   

	$fp = fsockopen ($url, 80, $errno, $errstr, 30);
	if (!$fp || $errno) return $errstr;

    @fputs($fp, "GET ".$req." HTTP/1.1\r\n");
    @fputs($fp, "HOST: ".$url."\r\n");
    @fputs($fp, "Connection: close\r\n\r\n");
	// read the body data
	$res = '';
	$headerdone = false;
	while (!feof($fp)) {
		$line = fgets ($fp, 1024);
		if (strcmp($line, "\r\n") == 0) {
		// read the header
		$headerdone = true;
		}
		else if ($headerdone)
		{
			// header has been read. now read the contents
			$res .= $line;
		}
	}	
	fclose ($fp);


	$obj = json_decode($res);
	if (isset($obj->error)) return false;
	// get user Info from first tweet
	if (isset ($obj[0])) 
	 	$twitter->user = $obj[0]->user;
	else
	 	return false;
	$i = 0;
	// get the tweets
	foreach ($obj as $o) {
	 	foreach ($o as $k=>$v) {
			if ($k != "user") {
				$t->$k = $v;
			}
		}
		$tweet[] = clone $t;
	$i++;
	if ($i == $count) break;
	}	

	$twitter->tweets = $tweet;

	$twitter = renderTwitter($twitter, $params);

	return $twitter;
}
}
function renderTwitter($twitter, $params) {
	// user 
	$twitter->user->image_html = "<img alt=\"".$twitter->user->screen_name."\"src=\"".$twitter->user->profile_image_url."\"/>";

	$twitter->user->image_html = "<img alt=\"".$twitter->user->screen_name."\"src=\"".$twitter->user->profile_image_url."\" width=\"".$params->get("userImgSize", 73)."px\"/>";

$twitter->user->twitter_link = "<a href=\"http://twitter.com/".$twitter->user->screen_name."\">".$twitter->user->screen_name."</a>";
$twitter->user->web_link = "<a href=\"".$twitter->user->url."\">".$twitter->user->url."</a>";

// tweets
foreach ($twitter->tweets as $t) {
	if ($params->get("relativeTime", 1) == 1) {
		$t->created_html = "<a href=\"http://twitter.com/".$twitter->user->screen_name."/status/".$t->id."\">".getRelativeTime($t->created_at)."</a>";
	}
	else {
		$t->created_html = "<a href=\"http://twitter.com/".$twitter->user->screen_name."/status/".$t->id."\">".JHTML::date($t->created_at)."</a>";
	}
	if (($params->get("showSource", 1) == 1)) {
		$t->created_html .= " from ".$t->source;

	}

	$t->image_html = "<img align=\"left\" alt=\"".$twitter->user->screen_name."\"src=\"".$twitter->user->profile_image_url."\" width=\"".$params->get("tweetImgSize", 32)."px\"/>";

	$t->text_html = preg_replace("/(http:\/\/[^\s]+)/", "<a href=\"$1\">$1</a>", $t->text);
}
return $twitter;
}


function getRelativeTime($date) {
$diff = time() - strtotime($date);
if ($diff<60)
return JText::sprintf("SECONDS AGO", $diff);
$diff = round($diff/60);
if ($diff<2)
return JText::_("ABOUT A MINUTE AGO");
if ($diff<60)
return JText::sprintf("MINUTES AGO", $diff);
$diff = round($diff/60);
if ($diff<2)
return JText::_("ABOUT AN HOUR AGO");
if ($diff<24)
return JText::sprintf("HOURS AGO", $diff);
$diff = round($diff/24);
if ($diff<2)
return JText::_("ABOUT A DAY AGO");
if ($diff<7)
return JText::sprintf("DAYS AGO", $diff);
$diff = round($diff/7);
if ($diff<2)
return JText::_("ABOUT A WEEK AGO");
if ($diff<4)
return JText::sprintf("WEEKS AGO", $diff);
return JHTML::date($date);
}

    asking the module developer would be the best option, after checking your followed the install instructions correctly.

    I get no parse errors are you sure you uploaded the right file in the right directory it seems unlikely that the module was released with such a basic mistake

      dagon;10971750 wrote:

      asking the module developer would be the best option, after checking your followed the install instructions correctly.

      I get no parse errors are you sure you uploaded the right file in the right directory it seems unlikely that the module was released with such a basic mistake

      I don't know the developer personally, but I can check his site to see if there is a forum. I was hoping it was something obvious that one of you could see it immediately. Strange that it doesn't cause you any errors.

      As for where it is installed, I have no reason to think it was installed in the wrong file. It's the helper.php file and it's under my sub-domain's folder. I would think the Joomla installer wouldn't put it where it doesn't belong.

      As far as I can tell, my problem isn't resolved, but you've indicated that there is nothing wrong with the code, so I have no other choice but to mark it resolved. Thanks to whomever put my long code in a scrolling area. It makes it better to read.

      Consider this un-resolved problem: Resolved.

      Dave

        You should get a text editor that lets you jump to a particular line (like notepad or notepad2). Counting lines is ridiculous.

        Try checking the previous line. I have found that if it complains about unexpected stuff on line N, then line N-1 often needs a syntax fix.

          I see that line 107 uses the keyword "clone". This is an OOP-related keyword and may not be meaningful in old versions of PHP. I could be wrong, but if you are using PHP 4 then that could be your problem.

            sneakyimp;10971884 wrote:

            I see that line 107 uses the keyword "clone". This is an OOP-related keyword and may not be meaningful in old versions of PHP. I could be wrong, but if you are using PHP 4 then that could be your problem.

            Indeed - the 'clone' keyword was made available in PHP 5, so if you're using PHP 4 then the above error message makes sense.

            Then again, running PHP 4 is almost as ridiculous as finding a text editor that doesn't let you go to a specific line number. :p

              bradgrafelman;10971896 wrote:

              Indeed - the 'clone' keyword was made available in PHP 5, so if you're using PHP 4 then the above error message makes sense.

              Then again, running PHP 4 is almost as ridiculous as finding a text editor that doesn't let you go to a specific line number. :p

              If not having PHP 5.0 on InMotionHosting server is the problem, who installs it? Me or InMotionHosting? If me, where does it go?

                I'm not sure exactly what your setup is, but I seriously doubt you have a dedicated server or virtual dedicated server. It's usually the hosting company's job to make sure PHP is installed and working. They may or may not cooperate. Ask them about it.

                  sneakyimp;10972030 wrote:

                  I'm not sure exactly what your setup is, but I seriously doubt you have a dedicated server or virtual dedicated server. It's usually the hosting company's job to make sure PHP is installed and working. They may or may not cooperate. Ask them about it.

                  I did. InMotionHosting will move my site to a php 5.x server for me...and FREE. So, since all my errors seem to be php release related, I really consider this problem resolved.

                  Thank you all for your patience with a true newbie who has yet to know what php stands for. That's for another day. I need to get my website running Joomla.

                  Regards,

                  Dave

                    Write a Reply...