2017-06-15 86 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標記爲複製品。 –

相關問題