解析错误:语法错误,文件意外结束[重复]

Posted

技术标签:

【中文标题】解析错误:语法错误,文件意外结束[重复]【英文标题】:Parse error: syntax error, unexpected end of file [duplicate] 【发布时间】:2017-06-25 19:02:25 【问题描述】:

它一开始可以工作,但是当我重新编辑它时,因为它看起来很乱,结果现在是错误的,有人可以帮助我吗?

我想我已经关闭了大括号和脚本,我不知道它有什么问题。

<?php
session_start();
require("functions.php");
if(!isset($_GET['id'])&&isset($_SESSION['username'])) header("Location: ?id=".getId($_SESSION['username']));
?>

<!-- HEAD -->

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>System of Account</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >

    <!-- Latest compiled and minified javascript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" ></script>

    <link rel="stylesheet" href="animate.css">
    <link href="fonts/css/font-awesome.min.css" rel="stylesheet">

    <link rel="shortcut icon" href="favicon.png">
    <link href="css/animate.min.css" rel="stylesheet">
   <link href="fonts/css/font-awesome.min.css" rel="stylesheet">
   <link rel="stylesheet" type="text/css" media="print" href="print.css" />
<!--<link type="text/css" rel="stylesheet" href="styles.css" />-->

<style>

     body
    margin: 0 auto;
    background-image:url("../clsimages/GG.jpg");
    background-repeat: no-repeat;
    background-size: 100% 720px;
    -webkit-background-size:cover;
    -moz-background-size:cover;
    -o-background-size:cover;



.container
    width: 65%;
    height:615px;
    background-color: rgba(52, 73, 94, 0.3);
    margin-top: 50px;
    border-radius:4px;
    border: 2px solid black;


</style>

 <style>
table
 float:left;
 border: 1px solid ;


</style>

    <style>

ul 
    width: 70%;
    margin: auto;


</style>

<style>

.div
    width: 250%;

.form-control
    border: 2px dashed #D1C7AC;
    width: 230px;
    color: #1E049E;
    onfocus="this.value=''
    font-weight: bold;
    font-size: 18px;
    font-family: "Times New Roman";




</style>

<script>
        function printDiv(divID) 
            //Get the HTML of div
            var divElements = document.getElementById(divID).innerHTML;
            //Get the HTML of whole page
            var oldPage = document.body.innerHTML;

            //Reset the page's HTML with div's HTML only
            document.body.innerHTML = 
              "<nav>" + 
              divElements + "</nav>";

            //Print Page
            window.print();

            //*Restore orignal HTML
           // document.body.innerHTML = oldPage;
      // window.location='print.php'; 
        
    </script>

</head>

<!-- BODY -->

<body>

<div id="container">

<?php 

  if(!isset($_SESSION['username']))
   

?>

 </br></br></br></br></br></br></br></br></br></br>

 <center>

 <font color="black"> <h2 class="form-signin-heading"> Please Login <i class="fa fa-sign-in"> </i></h2> </font>

  </br></br>

   <form action="authenticate.php"  class="form-signin" method="POST">
      <div class="input-group" style="margin-left:42%">
      <span class="input-group-addon" id="basic-addon1">Username:</span>
      <input type="text" name="username" class="form-control"  style="width:23%; height: 40px;" required><br />
        </div>

        </br>

         <div class="input-group" style="margin-left:42%">
         <span class="input-group-addon" id="basic-addon1" >Password:</span>
         <input type="password" name="password" id="inputPassword" class="form-control" placeholder="Enter Your Password" style="width:23%; height:40px;"required>
         </div>

         <br /> </br>

          <button class="btn btn-lg btn-primary btn-block" type="submit" style="width:25%;">  Login <i class="fa fa-sign-in"> </i> </button>
      </center>
     </form>

    <?php 

    if(isset($_GET["feedback"]))

      echo $_GET["feedback"]; 
  

  ?>

  <!-- NEXT PAGE -->


<?php 
  if(isset($_SESSION['username']))
  
     $profileUsersData = getUsersData(mysql_real_escape_string($_GET['id']));
    ?>
        <div id="menu">
            <a class="button" href="logout.php">Logout</a>
        </div>

<?php if(userExists(mysql_real_escape_string($_GET['id']))) ?>

<!--Button print -->

<button class="btn btn-default" onclick="javascript:printDiv('printablediv')"  class = "btn btn-success"  ><i class="fa fa-print"> </i> <b> Print the fees</b></button>

<!-- End -->



<!--PRINT -->


<div class="" id="printablediv">

  <p><img src="clsimages/STATEMENT.png"></p>


<div align="right">

<script>

        var y = new Date();
        var currentyear = y.getFullYear();
        var nextyear= y.getFullYear() +1;
        document.write("<p class='navbar-text pull-right'><font style = 'Impact' color = 'black'><h3> SY:<font color='blue'> "+ currentyear +"-"+ nextyear +" </h3></font></font></p>");

</script> </th>

</div>

<br>

<!-- Table -->

<table border='1' style='border-collapse:collapse; width:100%; border-bottom: hidden;'>
  <col style='width:50%;'>
  <tr>
    <td>
      <ul>
      <p><font size='2%' face='Arial'> <b>
        </br>

        <?php


            if(isset($_SESSION['username']))
    
         $profileUsersData = getUsersData(mysql_real_escape_string($_GET['id']));
        ?>


        <?php if(userExists(mysql_real_escape_string($_GET['id']))) ?>
        <div id="header">

        <?php echo 'STUDENT NAME: '. $profileUsersData['LastName'].", ".$profileUsersData['FirstName']. " ".$profileUsersData['MiddleName'].""; ?>

      </br></br>
        <?php echo ' </br> LEVEL: '. $profileUsersData['Level'].""; ?>
    </b>
  </ul>
</td>

<td>
  <ul>
    <p><font size="2%" face="Arial"><b> TELEPHONE: (63 2) 834-2915 
      </br></br>
      EMAIL: christianloveschool@yahoo.com 
    </p>
    </b>
  </ul>
  </table>

  <table border="1" style="border-collapse:collapse; width:100%;">
     <col style="width:50%;">
    <tr>
      <td>
        <ul>
        <font size="2%" face="Arial"> 
          <b>
        <?php echo ' </br> DATE: '. $profileUsersData['TuitionDate'].""; ?>
          <b>
          </br>
        <?php echo ' </br> TUITION FEE: '. $profileUsersData['Tuition'].""; ?>
          </br> </br>
         <?php echo ' </br> BOOKS: '. $profileUsersData['Books'].""; ?>
          </br> </br>
        <?php echo ' </br> SCHOOL/ PE UNIFORM: '. $profileUsersData['Uniform'].""; ?>
          </br> </br>
        <?php echo ' </br> OLD ACCOUNT: '. $profileUsersData['OldAcct'].""; ?>
        </br>
        </b>
       </ul>
      </td>
    </font>

      <td>
        <font size="2%" face="Arial">
        <ul>
          <b>
    <?php echo ' </br> BALANCE: '. $profileUsersData['Balance'].""; ?>
      </b>
      </ul>
      </td>
         </font>
    </tr>
  </table>

 <?php  else echo "Invalid ID"; ?>

 <?php  ?>

 <!-- RULES OF PAYMENT -->

 <table border="1" style="border-collapse:collapse; width:100%; border-top:hidden;">
    <tr>
      <td>
        <font size="3%" face="Arial">

          <ul>

             <b><u>RULES ON PAYMENT:</u></b>
        </font>

      </br></br>

        <font size="2%" face="Arial">

          1. Tuition fee payment must be made every 5th day of the scheduled payment scheme. </br></br>
          2.Payments should be made on time in order to take the exam needed. </br></br>
          3. Reservations and Miscellaneous fees are non-refundable. </br></br>
          4.A student who withdraws before the start of the school year shall be charged 50% on miscellaneous fee. </br></br>
          5. A student who transfers or otherswise withdraws within two weeks after the beginning of classes and has already paid the
          pertinent and other school fees in full may be charged to pay the whole amount of miscellaneous fees and the amount supposed tp be paid pertaining to tuition fee. </br></br>
          6. A student who transfers or withdraws within two weeks after the beginning of classes and has not yet paid the pertinent
          and other school fees shall be charged to pay the whole amount of miscellaneous fees in full and the amount supposed to be paid pertaining to tuition fee. </br></br>
          7. A student who withdraws any time after the second week of classes, full payment of tuition and miscellaneous fees shall be charged. </br></br>
          8. Discounts shall only be applied at the last payment. </br></br>
          9. Any discounts granted will be forfeited if the payment is delayed. </br></br>
          10. All fees should be paid in full before the end of the school year.
        </font>

        </br></br>

        <hr></hr>

        <br>

        <table>
    <font size="3%">
          Any discount granted will be <b> forfeited </b> if the payment is delayed.

    <br>

    <u> <font color="red"> <b>

     <br>

           Bring this notice upon payment and have the Examination Permit validated from the office.
    </font> </u>
    </table>

    </br></br>

          <font color="blue" size="3%">

            Contact the school if payment has been made, thank you.

         </u> </font> </b>

     </ul>
 </table>
</td>
</tr>

</div>
</div>

</body>
</html>

【问题讨论】:

if (isset($_SESSION['username'])) 在第 174 行,您没有关闭第一个打开的括号 你没有关闭 2 个括号 if(isset($_SESSION['username'])) 和 if(userExists(mysql_real_escape_string($_GET['id']))) 条件缺少右括号 【参考方案1】:

引用 I think i already closed the braces - 不,你没有。

您的代码包含 12 个 实例,但只有 10 个 实例。看起来问题之一是第 171 行上的大括号没有闭合,而且可能还有 1 个地方

【讨论】:

【参考方案2】:

以下if循环的括号没有闭合

 if(isset($_SESSION['username']))

<?php if(userExists(mysql_real_escape_string($_GET['id']))) ?>

【讨论】:

以上是关于解析错误:语法错误,文件意外结束[重复]的主要内容,如果未能解决你的问题,请参考以下文章

JSON解析错误语法错误意外结束输入

解析错误:语法错误,意外'[',期待')' [重复]

解析错误:意外的令牌,预期的“,”和语法错误:意外的令牌'['[重复]

Angular 2/Web Api - json 解析错误语法错误意外结束输入

解析错误:语法错误,意外'->'(T_OBJECT_OPERATOR),期望')'[重复]

我在尝试恢复节点模块时收到错误“错误意外结束 JSON 输入时解析'...“依赖项”:“tsli'”[重复]