【问题标题】:search engine syntax error?搜索引擎语法错误?
【发布时间】:2014-07-26 18:38:34
【问题描述】:

我不断收到语法错误提示

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>

【问题讨论】:

    标签: php forms mysqli


    【解决方案1】:

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

    这个:

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

    应该是这样的:

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

    【讨论】:

      猜你喜欢
      • 2014-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多