unparseble T_VARIABLE error

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
jpg
Forum Newbie
Posts: 1
Joined: Wed Dec 23, 2009 3:54 am

unparseble T_VARIABLE error

Post by jpg »

Hello

I'm having some trouble with a bit of code. Im getting the following error in my logs and I can't debug it:

Code: Select all

 
PHP Parse error: syntax error, unexpected T_VARIABLE in /path/to/file/on/server/createpage.inc on line 26
I've looked at loads of posts I found from google about this error and it seems that it's mostly caused by missing ; (semi-colon) or other symbol, but I have checked this over and over and i'm.

I knda hoped someone would be able to take a look and see if the error is more obvious to another pair of eyes. Here is the entire file:

Code: Select all

 
<?
 
function CreatePage($input)
{
    list($text) = $input;
 
    $result_dir = $Config['results_dir'];
    $tmpfname = tempnam ("$result_dir/", "");
 
    # I can't remember why I tacked on 2 random digits.
    $outbase = $tmpfname . rand(10, 99);
    $outfile = $outbase . ".html";
 
    $ipAddr = $_SERVER["REMOTE_ADDR"];
    $pasteID = basename($outbase);
 
    $token = sha1($pasteID . $ipAddr . $Config['token_salt']);
 
    # There is probably a better way to do this. tempnam() creates the
    # temporary file in the results directory, but we then need to strip
    # this off the front of the filename to make a shorter url.
    $rawout = $outfile;
    $rawout = preg_replace("/$result_dir\//", "", $rawout);
 
    if ($Config['short_results_path']) {
      $urlbase = $Config['short_results_path'];
    } else {
      $urlbase = $Config['site_domain'] . $Config['site_path'] . '/' $Config['results_dir'];
    }
    $pasteUrl = $urlbase . $rawout;
 
    $text = preg_replace("/=\{this-paste-url\}/", $pasteUrl, $text);
    $text = preg_replace("/=\{remove-paste-url\}/", $Config['site_domain'] . $Config['site_path'] . "remove.php?p=$pasteID&t=$token", $text);
 
    $fp = fopen($outfile, "w");
    fwrite($fp, $text);
    fclose($fp);
 
    unlink($tmpfname);
 
    return $pasteUrl;
}
 
?>
 
When I look at line 26 in my editor, it appears the error stems from this section of the code:

Code: Select all

if ($Config['short_results_path']) {
      $urlbase = $Config['short_results_path'];
    } else {
      $urlbase = $Config['site_domain'] . $Config['site_path'] . '/' $Config['results_dir'];
I would really appreciate any advice on this. Thank, Jamie
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: unparseble T_VARIABLE error

Post by flying_circus »

jpg wrote:

Code: Select all

if ($Config['short_results_path']) {
  $urlbase = $Config['short_results_path'];
} else {
  $urlbase = $Config['site_domain'] . $Config['site_path'] . '/' $Config['results_dir'];
}
Looks like you forgot a "." after '/' (line 4)
Post Reply