PHP Error (Parse error: syntax error, unexpected $end in )

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

User avatar
iankent
Forum Contributor
Posts: 333
Joined: Mon Nov 16, 2009 4:23 pm
Location: Wales, United Kingdom

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Post by iankent »

In the first bit of code you're missing a } at line 29 and 34 I think. The bracket on line 27 appears to be the closing bracket to the if statement, so 28 is closing the while loop.

The function usertable2() just doesn't have a closing bracket at all

In the second bit of code:
line 5 doesn't need return $in = stripslashes($in). you only need to do 'return stripslashes(in);'
other than that it looks ok.

Really can't see anything wrong with the => bit though...
squills
Forum Newbie
Posts: 12
Joined: Fri Nov 20, 2009 9:24 pm

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Post by squills »

ok I did alot of work on these files. None show any syntax errors :D

but now i get even a worst problem..
when i go to my home page it has all the code for the bittorrent.php file written on the site.. i took a picture soo you know what i mean...

Image

also added bittorrent.php code..was going to attach it cause soo long but wont let me attach it due to the .php name.

What a day! , I really apprate all the help you have given me..gives me hope lol..
:D

ok cant do that either as its too long lol.. well maybe you have an idea on why it would show the code from the bittorrent.php file?
User avatar
iankent
Forum Contributor
Posts: 333
Joined: Mon Nov 16, 2009 4:23 pm
Location: Wales, United Kingdom

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Post by iankent »

looks like there's a problem somewhere near "Unauthorized IP address" in bittorrent.php. Probably quotes or something are wrong so its treating everything after that line as text not PHP code.
squills
Forum Newbie
Posts: 12
Joined: Fri Nov 20, 2009 9:24 pm

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Post by squills »

well that image was not at the top of the screen this one is

Image


here is the top 300 or so lines of bittorrent.php...
line 16 is were the start of the code starts to write onto the screen

Code: Select all

<?
 
function cleanquotes(&$in){
    if(is_array($in)) return array_walk($in,'cleanquotes');
    return $in=stripslashes($in);
}
if(get_magic_quotes_gpc()){
    array_walk($_GET,'cleanquotes');
    array_walk($_POST,'cleanquotes');
    array_walk($_COOKIE,'cleanquotes');
    array_walk($_REQUEST,'cleanquotes');
}
 
function strip_magic_quotes($arr)
{
foreach ($arr as $k => $v)
{
if (is_array($v))
{ $arr[$k] = strip_magic_quotes($v); }
else
{ $arr[$k] = stripslashes($v); }
}
 
return $arr;
}
 
function local_user()
{
  return $_SERVER["SERVER_ADDR"] == $_SERVER["REMOTE_ADDR"];
}
//$FUNDS = "$2,610.31";
 
$SITE_ONLINE = true;
//$SITE_ONLINE = local_user();
//$SITE_ONLINE = false;
 
$invites = 10000;
$max_torrent_size = 10485760;
$announce_interval = 60 * 30;
$signup_timeout = 86400 * 3;
$minvotes = 1;
$max_dead_torrent_time = 6 * 3600;
 
// Max users on site
$maxusers = 75000; // LoL Who we kiddin' here?
 
// Max users on site
$maxusers = 10000;
 
// ONLY USE ONE OF THE FOLLOWING DEPENDING ON YOUR O/S!!!
$torrent_dir = "78698";    # FOR UNIX ONLY - must be writable for httpd user
//$torrent_dir = "C:/web/Apache2/htdocs/tbsource/torrents";    # FOR WINDOWS ONLY - must be writable for httpd user
 
# the first one will be displayed on the pages
$announce_urls = array();
$announce_urls[] = "http://racethe.net/announce.php";
$announce_urls[] = "http://racethe.net:82/announce.php";
$announce_urls[] = "http://racethe.net:83/announce.php";
 
if ($_SERVER["HTTP_HOST"] == "")                        // Root Based Installs Comment Out if in Sub-Dir
  $_SERVER["HTTP_HOST"] = $_SERVER["SERVER_NAME"];      // Comment out for Sub-Dir Installs
$BASEURL = "http://" . $_SERVER["HTTP_HOST"];           // Comment out for Sub-Dir Installs
 
//$BASEURL = 'http://domain.com';                       // Uncomment for Sub-Dir Installs - No Ending Slash
 
// Set this to your site URL... No ending slash!
$DEFAULTBASEURL = "http://racethe.net";
 
//set this to true to make this a tracker that only registered users may use
$MEMBERSONLY = true;
User avatar
iankent
Forum Contributor
Posts: 333
Joined: Mon Nov 16, 2009 4:23 pm
Location: Wales, United Kingdom

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Post by iankent »

If you use the browsers view source, does the broken output appear at the same point (i.e., "$v} if(is_array" or is there a bit before that? I really see no reason why it should suddenly start outputting at that point, which leads me to think there must be extra code being output before it. Could you copy and paste the output you see using view source too please?
squills
Forum Newbie
Posts: 12
Joined: Fri Nov 20, 2009 9:24 pm

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Post by squills »

yes it does end in same spot..here is the code ..its not all of it as i left off the bottom part if you want it all i can but its like 1300 lines.. THis is what it looks like color and all..

Code: Select all

[color=#00BFFF]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/color]
<[color=#B000FF]html[/color] xmlns=[color=#0040FF]"http://www.w3.org/1999/xhtml"[/color]>
<[color=#8000FF]head[/color]>
<[color=#8000FF]meta[/color] http-equiv=[color=#0040FF]"Content-Type"[/color] content=[color=#0040FF]"text/html; charset=UTF-8"[/color] [color=#FF0000]/[/color]>
<[color=#8000FF]title[/color]>RTN :: Login<[color=#8000FF]/title[/color]>
<[color=#8000FF]style[/color] type=[color=#0040FF]"text/css"[/color]>
<!--
body {
    font-family: "tahoma", "arial", "helvetica", "sans-serif";
    font-size: 8pt;
  background-color: #666666;
  background-image: url(images/bg.jpg);
  background-repeat: repeat-x;
  color: #222222;
  margin-top: 0px;
  margin-bottom: 0px;
}
-->
<[color=#B000FF]/style[/color]>
<[color=#B000FF]/head[/color]>
 
<[color=#B000FF]body[/color]>
[color=#FF40FF]<?[/color]
 
[color=#FF80FF]function cleanquotes(&$in){[/color]
 [color=#FF80FF]   if(is_array($in)) return array_walk($in,'cleanquotes');[/color]
   [color=#FF80FF] return $in=stripslashes($in);[/color]
[color=#FF80FF]}[/color]
[color=#FF80FF]if(get_magic_quotes_gpc()){[/color]
   [color=#FF80FF] array_walk($_GET,'cleanquotes');[/color]
    [color=#FF80FF]array_walk($_POST,'cleanquotes');[/color]
    [color=#FF80FF]array_walk($_COOKIE,'cleanquotes');[/color]
   [color=#FF80FF] array_walk($_REQUEST,'cleanquotes');[/color]
[color=#FF80FF]}[/color]
 
[color=#FF80FF]function strip_magic_quotes($arr)[/color]
[color=#FF80FF]{[/color]
[color=#FF80FF]foreach ($arr as $k =>[/color] $v)
{
if (is_array($v))
{ $arr[$k] = strip_magic_quotes($v); }
else
{ $arr[$k] = stripslashes($v); }
}
 
return $arr;
}
 
function local_user()
{
  return $_SERVER["SERVER_ADDR"] == $_SERVER["REMOTE_ADDR"];
}
//$FUNDS = "$2,610.31";
 
$SITE_ONLINE = true;
//$SITE_ONLINE = local_user();
//$SITE_ONLINE = false;
 
$invites = 10000;
$max_torrent_size = 10485760;
$announce_interval = 60 * 30;
$signup_timeout = 86400 * 3;
$minvotes = 1;
$max_dead_torrent_time = 6 * 3600;
 
 
User avatar
iankent
Forum Contributor
Posts: 333
Joined: Mon Nov 16, 2009 4:23 pm
Location: Wales, United Kingdom

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Post by iankent »

That's the HTML source from your browser? Its outputting the raw PHP file as HTML rather than parsing it. There's a few potential reasons why:
- your server doesn't like the <? tag - try <?php instead
- your file extension is wrong (make sure its .php?)
- php isn't installed correctly or your server/php aren't configured properly

Does a basic php file with <?php phpinfo(); ?> in work? If not, its likely a fault with your server/php config!
squills
Forum Newbie
Posts: 12
Joined: Fri Nov 20, 2009 9:24 pm

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Post by squills »

Thanks that seam to be right, i had to turn on magic quotes (<?php>) and my root directy was off by a folder!

Thanks Alot !!!
squills
Post Reply