0

So I have the below code. When I run it in the computer I used for development it executes with no errors or warnings, but when i try to open it from a different computer it gives me a parse error. The error is the PHP code after the closing body tag.

The error am getting is Parse error: syntax error, unexpected end of file in the line

<?
    include("php/dbconnection.php");
    include("php/action.php");
    error_reporting(0);
    session_start();

    if(!$_SESSION['auth']) {
        session_unset();
        session_destroy();
        header('location:index.php');
    }
    else {
      $currentTime = time();      
      if($currentTime > $_SESSION['expire']) {
        session_unset();
        session_destroy();
        header('location: index.php');
      }
      else {
        $_SESSION['start'] = time();
        $_SESSION['expire'] = $_SESSION['start'] + (10 * 60);
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="style.css">
    <link href="fonts" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="script.js"></script>
    <title>Administrator</title>
</head>
<body>
    <!-- Nav bar -->
    <header>
        <div class="navigation">
            <div class="navbar">
                <h4><span>Patient's Disease and Medication Monitoring System</h4>
            </div>
            <div class="navbar-user">
                <h4>(<?php echo $_SESSION['loggedin']; ?>)</h4>
            </div>
            <div class="clear-box"></div>   
        </div>          
    </header>

    <!-- Main body content-->
    <div class="container">
        <div id="main">
            <div class="side-menu">
                <ul>
                    <li><a href="admin.php">Home</a></li>
                    <?php 
                        $userlevel = $_SESSION['loggedin'];
                        if($userlevel == 'superadmin'){
                            echo "<li><a href='pages/addhospital.php'>Hospital Info</a></li>";                  
                        }
                        else{
                            //NOTHING
                        }
                    ?>                  
                    <li><a href="pages/addusers.php">Register User</a></li>
                    <li><a href="pages/viewusers.php">View Users</a></li>
                    <li><a href="pages/changepassword.php">Change Password</a></li>
                    <li><a href="php/logout.php" name="logoutbutton">Logout</a></li>
                </ul>
            </div>
            <div class="main-content">
                <div class="tabs">
                    <span>Hello There</span>
                </div>
            </div>
        </div>
    </div>

    <!--This is the footer for all pages-->
    <div class="footer">
        <p>Designed by UDOM Students</p>
    </div>
</body>

 <?php
        }
      }
 ?>

</html>
  • Please add the complete syntax error. It should tell the line number and filename. – Leroy May 23 '21 at 14:55
  • Why `` at the top and ` – AbraCadaver May 23 '21 at 14:56
  • First tip, don't use short tags like `` they may be not allowed in some configs, use ` – biesior May 23 '21 at 14:58
  • 1
    And removed in PHP 8 – AbraCadaver May 23 '21 at 15:00
  • Excuse my late reply. After playing around with the php.ini config file I discovered that short tags option was given the value Off. After replacing it with On it now works. Thanks everyone. – Charles Venny Jun 03 '21 at 11:55
  • We tried to convince you, that you should replace all occurrences in your code instead of enabling this in your php.ini file for many reasons. In very short version: short tags generates problems and should be aboided. For more reading just google it or see [other questions like that](https://stackoverflow.com/a/200666/1066240). – biesior Jun 04 '21 at 11:37

0 Answers0