-2

このスクリプトは、要求したデータ (Id、Dsc、School) を表示していますが、20 行目でエラーが発生しています。

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

解析エラー: C:\wamp\www\unit5\scripts\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

1 に答える 1

1

私はフォーマット、インデントを調べてクリーンアップし、引用符のヒープ全体を変更しました.

これを試して:

<?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();
    }
?>
于 2012-07-19T10:50:59.957 に答える