搜索引擎语法错误


search engine syntax error?

我一直得到语法错误,说

Parse error: syntax error, unexpected '{' in C:'wamp'www'search.php on line 5

我看了看第5行,没有发现有什么问题。我做错了什么?

$result_tb = "";
if (!empty($_POST['SEARCH']) && !empty($_POST['search_value']) {
   $e = $_POST['search_value'];
   $query = 'SELECT * FROM register WHERE ' .
           "first_name LIKE '%$e%' OR " .
           "middle_name LIKE '%$e%' OR " .
           "last_name LIKE '%$e%' OR " .
           "login_name LIKE '%$e%' ";
   $query_result = $mysqli_db->query($query);
   $result_tb = '<table cellspacing="5" cellpadding="5">';
   while ($rows = $query_result->fetch_assoc()) {
      foreach ($rows as $k => $v) {
         $result_tb .= '<tr><td>' . $k . '</td><td>' . $v . '</td></tr>';
      }
   }
   $result_tb .='</table>';
   $mysqli_db->close();
}
?>
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Search</title>
   </head>
   <body>
      <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
         <table>
            <tr>
               <td>
                  <input type="text" name="search_value" size="30" maxlength="30"/>
               </td>
               <td>
                  <input type="submit" name="SEARCH" value="Search"/>
               </td>
            </tr>
         </table>
      </form>
      <?php echo $result_tb; ?>
   </body>
</html>

你需要看起来更好,关闭你打开的每个括号。

:

if (!empty($_POST['SEARCH']) && !empty($_POST['search_value']) {

应该是这样的:

if ( !empty($_POST['SEARCH']) && !empty($_POST['search_value']) ) {
                                       // this one was missing  ^