Parse error: syntax error, unexpected '}' on line

时间:2017-06-15 10:14:24

标签: php html

Me and my mate we're trying to solve this for over 1.5 hours, we are still getting the same and tried almost everything we could. Could anyone help us do that? ,This is error what we're getting:

( ! ) Parse error: syntax error, unexpected '}' in C:\aboamirtbk\www\edit.php on line 141

Thanks to everyone who will help. :)

<html>
<body>
<center>


<?php include("table_php().php"); 

if(!empty($_SESSION['LoggedIn0']) && !empty($_SESSION['student_number']))
{
?>
<br><br>
<?php
     include "base.php";
 // Check connection
 if (mysqli_connect_errno())
   {
   echo "Failed to connect to MySQL: " . mysqli_connect_error();
   }
   $username = $_SESSION['student_number'];
  if ($result = $con->query("SELECT * FROM students WHERE students.student_number = '".$username."'"))
                        {
                                if ($result->num_rows > 0)
                                {   
                                    echo "<table border='1' cellpadding='10'>";
                                        echo " <tr> <th><font color=red size=5>שם</font></th>  <th><font color=red size=5>שם משפחה</font></th> <th><font color=red size=5>סיסמה</font></th> <th><font color=red size=5>דואר אלקטרוני</font></th><th><font color=red size=5>Edit</font></th> </tr>";
                                        while ($row = $result->fetch_object())
                                        {
                                                echo "<tr>";

                                                //echo "<td>" . $row->ID. "</td>";<th>ID</th>

                                                echo "<td>" . $row->student_name . "</td>";
                                                echo "<td>" . $row->student_last . "</td>";
                                                echo "<td> Can't Show</td>";
                                                echo "<td>" . $row->student_email . "</td>";
                                                echo "<td><a href='edit1.php?id=" . $row->student_name . "'>Edit</a></td>";
                                            //    echo "<td><a href='delswim.php?id=" . $row->student_name . "'>Delete</a></td>";
                                                echo "</tr>";
                                        }

                                        echo "</table><br>";

                                }
                                else
                                {
                                        echo "No results to display!";
                                }
                        }
                        else
                        {
                                echo "Error: " . $con->error;
                        }
                        if ($result2 = $con->query("SELECT * FROM students WHERE students.student_number = '".$username."'"))
                        echo "<table border='1' cellpadding='10'>";
                                        echo " <tr> <th><font color=red size=5>מספר סטודנט</font></th>  <th><font color=red size=5>מוסד לימוד</font></th> <th><font color=red size=5>כתובת סטודנט</font></th> </tr>";
                                        while ($row2 = $result2->fetch_object())
                                        {
                                                echo "<tr>";

                                                //echo "<td>" . $row->ID. "</td>";<th>ID</th>

                                                echo "<td>" . $row2->student_number . "</td>";
                                                echo "<td>" . $row2->student_collage . "</td>";
                                              //  echo "<td> Can't Show</td>";
                                                echo "<td>" . $row2->student_address . "</td>";
                                              //  echo "<td><a href='edit1.php?id=" . $row->student_name . "'>Edit</a></td>";
                                            //    echo "<td><a href='delswim.php?id=" . $row->student_name . "'>Delete</a></td>";
                                                echo "</tr>";
                                        }

                                        echo "</table>";
                        $con->close();


                ?>


</center>
</body>
</html>

                        <?php
} elseif(!empty($_POST['username']) && !empty($_POST['password']))
      $username = mysqli_real_escape_string($con,$_POST['username']);
    $password = md5(mysqli_real_escape_string($con,$_POST['password']));
    $id_student = mysqli_real_escape_string($con,$_POST['id_student']);


    $checklogin = mysqli_query($con,"SELECT * FROM `students` WHERE student_number = '".$username."' AND password = '".$password."' AND id_student= '".$id_student."'");
    $check_var = mysqli_query($con,"SELECT * FROM groups WHERE student_number = '".$username."'");
    $_SESSION['LoggedIn0'] = 1;

    $checklogin = mysqli_query($con,"SELECT * FROM `students` WHERE student_number = '".$username."' AND password = '".$password."' AND id_student= '".$id_student."'");
    $check_var = mysqli_query($con,"SELECT * FROM groups WHERE student_number = '".$username."'");

    if(mysqli_num_rows($checklogin) == 1)
    {
        $row = mysqli_fetch_array($checklogin);
             $row1 = mysqli_fetch_array($check_var);
        $email = $row['student_name'];
        $id = $row['id_student'];
        $studentlast = $row['student_last'];
        $email1 = $row['student_email'];
        $birth = $row['student_datebirth'];
        $last = $row['last'];
        $student_address = $row['student_address'];
        $student_collage = $row['student_collage'];
        $_SESSION['id_student'] =$id;

        $_SESSION['student_number'] = $username;
      $_SESSION['last'] = $last;
        $_SESSION['student_name'] = $email;
        $_SESSION['student_last'] = $studentlast;
        $_SESSION['student_email'] = $email1;
        $_SESSION['student_datebirth'] = $birth;
        $_SESSION['student_address'] = $student_address;
        $_SESSION['student_collage'] = $student_collage;

    $_SESSION['LoggedIn0'] = 1;

        echo "<h1>&#1492;&#1510;&#1500;&#1495;&#1514;&#1501; &#1500;&#1492;&#1514;&#1495;&#1489;&#1512; &#1500;&#1508;&#1512;&#1493;&#1508;&#1497;&#1500; &#1513;&#1500;&#1499;&#1501; </h1>";
        echo "<p>&#1488;&#1504;&#1488; &#1492;&#1502;&#1514;&#1503; , &#1500;&#1492;&#1499;&#1497;&#1503; &#1488;&#1514; &#1504;&#1514;&#1493;&#1504;&#1497;&#1498; &#1489;&#1508;&#1512;&#1493;&#1508;&#1497;&#1500;..</p>";
        echo "<meta http-equiv='refresh' content='2;index.php' />";
    }
    else
    {
        echo "<h1>&#1492;&#1499;&#1504;&#1505;&#1514; &#1504;&#1514;&#1493;&#1504;&#1497;&#1501; &#1500;&#1488; &#1504;&#1499;&#1493;&#1504;&#1497;&#1501;</h1>";
        echo "<p><strong>&#1514;&#1489;&#1491;&#1493;&#1511; &#1492;&#1505;&#1497;&#1489;&#1493;&#1514; &#1492;&#1489;&#1488;&#1493;&#1514; :</strong></p>";
          echo "<ol start='1' type='1'>";
          echo "<li>1. &#1502;&#1505;&#1508;&#1512; &#1494;&#1492;&#1493;&#1514; / &#1502;&#1505;&#1508;&#1512; &#1505;&#1496;&#1493;&#1491;&#1504;&#1496; / &#1505;&#1497;&#1505;&#1502;&#1492; &#1513;&#1490;&#1493;&#1497;&#1497;&#1501;</li>";
            echo "<li>&nbsp  &nbsp  &nbsp  &nbsp  &nbsp  2. &#1497;&#1513; &#1514;&#1511;&#1500;&#1492; &#1489;&#1513;&#1512;&#1514; &#1513;&#1500; &#1488;&#1514;&#1512; , &#1493;&#1514;&#1489;&#1491;&#1493;&#1511; &#1489;&#1494;&#1502;&#1503; &#1488;&#1495;&#1512; &#1489;&#1489;&#1511;&#1513;&#1492;.</li>";
              echo "<li>&nbsp  &nbsp  &nbsp  &nbsp  &nbsp &nbsp  &nbsp  &nbsp  &nbsp  &nbsp  &nbsp  &nbsp  &nbsp &nbsp  &nbsp &nbsp  &nbsp  &nbsp &nbsp &nbsp &nbsp 3. &#1514;&#1489;&#1491;&#1493;&#1511; &#1502; CAPS LOCK &#1489;&#1502;&#1511;&#1500;&#1491;&#1514; &#1513;&#1500;&#1498; , &#1488;&#1501; &#1499;&#1514;&#1489;&#1514; &#1504;&#1499;&#1493;&#1503; &#1489;&#1513;&#1496;&#1495; &#1513;&#1500; &#1505;&#1497;&#1505;&#1502;&#1492; &#1488;&#1493; &#1500;&#1488; .</li>";
                echo "<li>&nbsp  &nbsp  &nbsp &nbsp &nbsp &nbsp  &nbsp &nbsp 4. &#1492;&#1495;&#1513;&#1489;&#1493;&#1503; &#1513;&#1500;&#1498; &#1504;&#1506;&#1493;&#1500; &#1500;&#1508;&#1497; &#1492;&#1490;&#1491;&#1512;&#1492; &#1492;&#1504;&#1493;&#1492;&#1500; , &#1500;&#1498; &#1500;&#1502;&#1494;&#1499;&#1497;&#1512;&#1493;&#1514; &#1513;&#1500;&#1499;&#1501;.</li>";
                  echo "<li>5. &#1492;&#1508;&#1512;&#1502;&#1496;&#1512; &#1513;&#1500; &#1512;&#1493;&#1493;&#1496;&#1512; 10.0.0.2 &#1513;&#1490;&#1493;&#1497; &nbsp &nbsp  &nbsp  &nbsp &nbsp  </li>";
                    echo "<li>6. &#1514;&#1504;&#1505;&#1492; &#1506;&#1493;&#1491; &#1508;&#1506;&#1501;  &#1491;&#1512;&#1498;  <a href=\"index.php\">&#1499;&#1488;&#1503;</a>. &nbsp  &nbsp  &nbsp  &nbsp  &nbsp  &nbsp &nbsp  &nbsp  &nbsp  &nbsp &nbsp  </li>";

                    echo "</ol>";
           /*      echo "<br><h3 align='center'> &#1511;&#1493;&#1491; &#1513;&#1490;&#1497;&#1497;&#1492; : &#1514;&#1511;&#1500;&#1492; &#1502;&#1488;&#1490;&#1512; &#1504;&#1514;&#1493;&#1504;&#1497;&#1501; 501 </h3>";           
            */
    }
}
else
{

    include "die.php";

}


?>

3 个答案:

答案 0 :(得分:0)

You have missed opening brace of elesif added at line no 84

                            <?php
    } elseif(!empty($_POST['username']) && !empty($_POST['password']))
{ // you missed opening brace here

答案 1 :(得分:0)

You forgot to add opening curly brace for else if . Please check below modification:

. . .

<?php
} elseif(!empty($_POST['username']) && !empty($_POST['password'])) {
      $username = mysqli_real_escape_string($con,$_POST['username']);
    $password = md5(mysqli_real_escape_string($con,$_POST['password']));

. . .

答案 2 :(得分:0)

I think this is the caused of the problem

if ($result2 = $con->query("SELECT * FROM students WHERE students.student_number = '".$username."'"))

There are no curly brackets of that condition.