1

I am getting Parse error: syntax error, unexpected end of file on line 262 (last line of the code). I used some php code checkers, but I couldn't find something wrong ... Here is the code

<?php include('head.php'); ?>
<? ini_set('display_errors', "On"); error_reporting(E_ALL); include('header.php'); ?>
  <?php include('menu.php'); ?>
        <?php if(!isset($_SESSION['steamid'])) { ?>
          <?php } else { ?>
                  <?php echo $detailsWrapClass; ?>
                  <?php echo $steamprofile['personaname'];?>
                  <?php echo "<img src=\"".$steamprofile['avatarfull']."\" class=\"avatar\" width=\"60px\">";?>
            <? } ?>
              <? include ('mini-chat.php'); ?>
                <? include ('game.php'); ?>

head.php

<? require('steamauth/steamauth.php'); ?>
<? 
    if(isset($_SESSION["steamid"])) {
include_once('steamauth/userInfo.php');}
?>
<?
if ($steamprofile['steamid'] == 1 || $steamprofile['steamid'] == 2 || $steamprofile['steamid'] == 3) {
    exit('<script language="JavaScript">window.location.href = "/banned"</script>');
}
?>

header.php

<?php
    if(!isset($_SESSION['steamid'])) { 
    } else { 
    include ('steamauth/userInfo.php');
    ?>
<?php echo $steamprofile['steamid'];?></div>
<?php
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
$rstr = generateRandomString(32);
$m = new MongoClient("mongodb://ip:28724");
$db = $m->admin;
$collection = $db->authdb;
$document12 = array( "userid" => $_SESSION['steamid'] );
$collection->remove($document12);
$document = array( "userid" => $_SESSION['steamid'], "token" => $rstr );
$collection->save($document);
echo $rstr;
?>
<?php 
}?>

mini-chat.php

<?php if(isset($_SESSION['steamid'])) {
      echo '<div id="nav-two-b" class="content-container-row1-chat-input">
            <input type="text" name="" id="text-massage" />
            <button class="-btn -btn-primary" id="send_massage"><span class="-sp -sp-enter"></span></button>
          </div>';
             }
      else {
                echo '';
            }
            ?> 

game.php

            <?php if(!isset($_SESSION['steamid'])) {$detailsWrapClass = 'hidden'; $enterClass = ''; $text_game = 'Вступай в игру сейчас и выиграй: '; ?>
                <?php } else {$text_game = 'БАНК: '; $detailsWrapClass = ''; $enterClass = 'hidden'; ?>
                  <?php } ?>
                        <?php echo $text_game; ?><span id="jackpot-temp">

                        <?php if(!isset($_SESSION['steamid'])) {?>
                        <?php } else {?>
                        <? } ?>
                        <?php echo $detailsWrapClass; ?>
DaNy3LL
  • 43
  • 6
  • And how do you expect us to help if you don't post the code? A link to an arbitrary site is _not_ a replacement for that. That is clearly explained in the "how and what to ask" section here. Instead please reduce your code as far as possible so that the effect still persists. That is what you have to do anyway when trying to find the cause of the issue. – arkascha Nov 08 '15 at 12:07
  • @arkascha I did that because if I post all the code it says that most of my post is code. Since I don't know what's wrong, I don't know how I could reduce the code ... – DaNy3LL Nov 08 '15 at 12:33
  • Obviously you could simply remove all the html code in between the few php bits, since the markup obviously cannot lead to a syntax error. – arkascha Nov 08 '15 at 12:38
  • @arkascha I've done that and updated the first post – DaNy3LL Nov 08 '15 at 12:46
  • OK, there is no issue in that code piece that would lead to a syntax error. That means that the culprit mist be hidden in one of the included files. Same approach as before applies. Sorry, but this is how one tracks down such issues. or one uses an IDE with syntax analysis that actually marks files holding invalid syntax. – arkascha Nov 08 '15 at 12:49
  • @arkascha I've added the included files – DaNy3LL Nov 08 '15 at 13:00
  • File `header.php` looks pretty broken to me. not only in style (why these countless php open and close tags? I hope you do not mix html and php in all those include files? ) but also in syntax. In general: a good strategy is to comment out one include after another and check for syntax validity in between. That should make it easier to find out which script is broken. That way you also find scripts you still have forgotten here. – arkascha Nov 08 '15 at 13:04
  • I've only deleted the html from those files and posted only the php bits. I did not wrote this code, I got it from someone. I tried commenting includes one by one, but the error is still there. – DaNy3LL Nov 08 '15 at 13:34
  • That last sentence sounds strange. If you have no include left and the code is trivial, then you should not have an error. If you still do, then you overlooked something. You probably look in the wrong files. Maybe there is a php `auto_prepend` directive set somewhere? Oh, and make sure that you do not read the same error message from the browsers cache or a proxy inbetween you and the server :-) – arkascha Nov 08 '15 at 13:35

1 Answers1

1

You opened an else case in line 46 but do not close that until the end of the file is reached. So PHP says that file ends unexpectedly - because there is an open condition.

Richard
  • 2,840
  • 3
  • 25
  • 37