语法错误,但代码看起来很好......我猜?

时间:2014-05-18 15:32:20

标签: php syntax get

我在第30行遇到语法错误,其中else子句是。

<!DOCTYPE html>
<?php
session_start();

require "users.php";
require "connect.php";

  if(!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] == false) { 
      header('Location: index.php'); 
      exit(); 
  }

if (!empty($_GET)){
  $link = $_GET;
  while(list($sleutel, $waarde) = each($link)){
    $key = $sleutel;
    $md5 = $waarde;
  }

  $query = mysql_query('SELECT * FROM Virtualbox WHERE md5naam ="'.$md5.'"')or die(mysql_error());
  $row = mysql_fetch_array($query);

  if($md5 == $row['md5naam']){
    $resultaat = '<tr>
                    <td>'.$row["virtualboxnaam"].'</td>
                    <td>'.$row["operating_system"].'</td>
                    <td>'.$row["omschrijving"].'</td>
                  </tr>'
  } else { **//this is line 30**
    $resultaat = "";
  }
}
?>

在同一页面的HTML中,我有一个从PHP查询生成的锚点:

<div id="tab2" class="tab2">
              <div class="accordion">
                <?php
                  $result = mysql_query("SELECT * FROM Virtualbox WHERE user_id = ". $_SESSION["user_id"]);
                  $teller = 1;

                      while($select = mysql_fetch_array($result)){
                        echo('<div class="accordion-section">');
                        echo('<a class="accordion-section-title" href="#accordion-'.$teller.'">' . $teller . '. ' .$select["titel"] .'</a>');
                        echo('<div id="accordion-'.$teller.'" class="accordion-section-content">');
                          echo('<h2>Titel</h2>
                                <p>'.$select["titel"].'</p><br>
                                <h2>Operating System</h2>
                                <p>'.$select["operating_system"].'</p><br>
                                <h2>Virtualbox</h2>
                                <p>'.$select["virtualboxnaam"].'</p><br>
                                <a href="myVB.php?md5='.$select["md5naam"].'">'.$select["md5naam"].'</a>');
                              echo('</div>');
                        echo('</div>');
                        $teller++;
                      }
                 ?>
              </div><!--end .accordion-->

请不要过于严厉地评判我,我只是在一个月前学习PHP。

1 个答案:

答案 0 :(得分:1)

您在;之前错过了else

  if($md5 == $row['md5naam']){
    $resultaat = '<tr>
                    <td>'.$row["virtualboxnaam"].'</td>
                    <td>'.$row["operating_system"].'</td>
                    <td>'.$row["omschrijving"].'</td>
                  </tr>'; // added ;
  } else { **//this is line 30**
    $resultaat = "";
  }