搜索引擎语法错误?

时间:2014-07-26 18:38:35

标签: php forms mysqli

我一直收到语法错误

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>

1 个答案:

答案 0 :(得分:0)

你需要看起来更好并关闭你打开的每个支架。

这:

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

应该是这样的:

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