2012-07-19 85 views
-2

此腳本顯示我請求(ID,DSC,學院)的數據,但即時得到錯誤第20行PHP腳本 - 意外「}

{ 
    if ($row['suspended']==1){ 

解析錯誤:語法錯誤,意想不到的‘}’ C:\ WAMP \ WWW \頁免費\腳本\上線meminclude.php 20

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

$query = "SELECT id,dsc, school FROM module WHERE dsc LIKE '%%%s%%'"; 

$link = @ mysql_query($query); 
    if (!$link) { 

header("location:../account/account.master.php?page=invalid&errorcode=1"); 
    die(); 
} 

$i=0; 
$status=""; 

while ($row = mysql_fetch_array($link, MYSQL_ASSOC)) 


{ 
    if ($row['suspended']==1){ 


$status="SUS"; 
    } 
    echo " 

<tr id='row$i' class='trows'>". 
     " 
<td id='id$i'>".$row['id']."</td>". 
     " 
<td id='dsc$i'>".$row['dsc']."</td>". 
     " 
<td id='school$i'>".$row['school']."</td>". 
     " 
</td>". 
     " 
<td><input type='radio' name='whome' id='showMe$i' onclick='showMem($i)' /></td> 
"; 
     if ($status=='SUS'){ 
      echo " 
<td><input type='radio' name='suspend' checked='checked' disabled='disabled' /></td> 
"; 
     } else { 
      echo " 
<td><input type='radio' name='suspend' id='suspend$i' onclick='suspendMem($i)' /></td> 
"; 
     } 
     echo " 
<td><input type='radio' name='delete' id='delete$i' onclick='deleteMe($i)' /></td> 
". 
     " 
<td id='status$i'>".$status."</td></tr>"; 
    $i++; 
    $status=""; 
} 
?> 

腳本此處引用:

<script type="text/javascript"> 
    $(document).ready(function() { 
      var numrecs=$(".trows").length; 
      var me= $('#th1').html()+" - "+(numrecs)+" Records in Table."; 
      $('#th1').html(me); 
      RiVm=numrecs; 
     }); 
    </script> 
    <link rel="stylesheet" href="../css/results.css" type="text/css" /> 
    <div id="appleft"> 
     <form id="myapprovelist" method="post"> 
     <fieldset style="border:none"> 
     <table id="myTable"> 
      <tr><th id="th1" colspan="10">Active Membership List</th></tr> 
      <tr class="red"> 
      <th>ID</th> 
      <th>DSC</th> 
      <th>School</th> 
      </tr> 
      <?php include("../scripts/meminclude.php")?> 
     </table> 
     </fieldset> 
     </form> 
     </div> 
     <div id="appright"> 
     <img id="theBroon" src="" alt="" /><br /> 
     <span id="myBroon"></span> 
     </div> 
    </div> 
    <div style="clear:both">  
    </div> 
+4

你應該對自己的修正瑣碎的分析錯誤,不開這樣的主題對這些錯誤進行排序。 – 2012-07-19 10:42:57

+0

它看起來不錯,粘貼'dbconnect1.php'代碼。 – rogal111 2012-07-19 10:43:17

+0

showMem($ i)改爲showMem({$ i}) – 2012-07-19 10:45:19

回答

1

我經歷了和c依靠格式化,縮進,並改變了一大堆引號。

試試這個:

<?php 
    include("dbconnect1.php"); 
    $query = "SELECT id,dsc, school FROM module WHERE dsc LIKE '%%%s%%'"; 
    $link = @ mysql_query($query); 
    if (!$link) 
    { 
     header("location:../account/account.master.php?page=invalid&errorcode=1"); 
     die(); 
    } 

    $i=0; 
    $status=""; 
    while ($row = mysql_fetch_array($link, MYSQL_ASSOC)) 
    { 
     if ($row['suspended']==1) 
     { 
      $status="SUS"; 
     } 
     echo "<tr id='row".$i."' class='trows'><td id='id".$i."'>".$row['id']."</td><td id='dsc".$i."'>".$row['dsc']."</td><td id='school".$i."'>".$row['school']."</td></td><td><input type='radio' name='whome' id='showMe".$i."' onclick='showMem(".$i.")' /></td>"; 
     if ($status=='SUS') 
     { 
      echo "<td><input type='radio' name='suspend' checked='checked' disabled='disabled' /></td>"; 
     } 
     else 
     { 
      echo "<td><input type='radio' name='suspend' id='suspend".$i."' onclick='suspendMem(".$i.")' /></td>"; 
     } 
     echo "<td><input type='radio' name='delete' id='delete".$i."' onclick='deleteMe(".$i.")' /></td><td id='status".$i."'>".$status."</td></tr>"; 
     $i++; 
     $status=""; 
    } 
?> 

和DBCONNECT:

<?php 
    $hostname = "localhost"; 
    $username = "root"; 
    $password = ""; 
    $dbase = "timetable"; 
    $link = @ mysql_connect($hostname, $username, $password); 
    if (!$link) 
    { 
     header("location:../account/account.master.php?page=invalid&errorcode=1"); 
     die($link); 
    } 
    $db_selected = @ mysql_select_db($dbase, $link); 
    if (!$db_selected) 
    { 
     header("location:../account/account.master.php?page=invalid&errorcode=1"); 
     die(); 
    } 
?> 
+0

非常感謝你這樣做,但它沒有任何區別 – Ross 2012-07-19 10:56:15

+0

腳本也在這裏引用: – Ross 2012-07-19 10:56:34

+0

我不認爲你的鏈接在那裏工作chap,你可以編輯你的問題,包括你的整個代碼?備用支架必須在其他地方。 – Fluffeh 2012-07-19 10:57:57