2017-06-15 130 views
0

我和我的伙伴我们正试图解决这个问题超过1.5小时,我们仍然相同并尝试几乎所有可能的东西。 任何人都可以帮助我们做到这一点? ,这是我们得到的错误:解析错误:语法错误,在线发生意外的'}'

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

感谢每个人的帮助。 :)

<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"; 

} 


?> 
+0

和141行是哪一行? – arkascha

+2

这可能是因为您在发布的代码部分中间的'elseif'后简单地忘记了一个大括号。 – arkascha

回答

0

你已经错过了开幕elesif的支柱,在加号线84

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

认真吗?只要把你已经改变的地方,为什么,而不是另一个怪物代码转储。 – CD001

+0

感谢提醒,我在编辑答案,但系统问题 –

+1

这是一个常见问题,应作为重复关闭。它不应该被回答。将来请仅将a标记为复制品。 –

0

你忘了添加了其他如大括号。请检查以下修改:

。 。 。

<?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'])); 

。 。 。

+0

这是一个常见问题,应作为副本关闭。它不应该被回答。将来请仅将a标记为复制品。 –

0

我认为这是造成问题的

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

有一些条件没有大括号。

+0

不需要与那一个 - 技术上整条线是'if($ result2 = $ con> query(“SELECT * FROM students WHERE students.student_number ='”。$ username。“'”))echo “

”;; – CD001

+0

是的,但是当涉及到很多if else语句时,最好将它包括在大括号中,这样它就不会混淆。但是谢谢。 –

+0

这是一个常见问题,应作为副本关闭。它不应该被回答。将来请仅将a标记为复制品。 –

相关问题