2017-04-09 24 views
-2

このコードは、私に予期しないファイルの終わりを与えています。どんな助け?
多くの異なるクエリを持つsinmpleページを作成しようとしています。私は1つの場所に物事を保持し、時間を節約するように1つのページを作っています。誰もが何か推奨事項を持っている?予期しないファイルの終わり、HTML PHPとMYSQL

<?php 
    $host="127.0.0.1"; 
    $username="root";  
    $pword=""; 
    $database="spm"; 

    require("db_connection.php"); 
    //for searching by customer name 
    $customername1 = $_POST['customername1']; 
    //variables for inserting new restaurant 
    $restname = $_POST['restname']; 
    $restaddress = $_POST['restaddress']; 
    $resthomephone = $_POST['resthomephone']; 
    $restcolpoints = $_POST['restcolpoints']; 
    $restdelpoints = $_POST['restdelpoints']; 

?> 

<html> 
    <head> 
     <title>Database search</title> 
    </head> 
    <body> 
<?php 
     $custidtosearch = ""; 
      $query_string = "SELECT custID FROM customertable WHERE custname ='".$customername1."'"; 
      if ($result = $mysqli -> query($query_string)) { 
       while ($row = $result -> fetch_object()) { 
        $custidtosearch = $row->dateid; 
       //echo $custidtosearch; 
       } 

      Echo "</table>"; 
      $result->close(); 
      }else{ 
       echo ("there was an error or there was no query"); 
      } 

      $query_string = "SELECT * FROM orderlist WHERE custid = '".$custidtosearch."'" ; 
      //echo $query_string; 
      if ($result = $mysqli -> query($query_string)) { 
       echo "<table border = '1'>"; 
       echo "<tr><th> Customer Name</th> <th>Order ID</th> <th>Customer ID</th> <th>Restaurant ID</th> <th>Order points</th> <th>Customer Points used</th></tr>"; 
       while ($row = $result -> fetch_object()) { 
        Echo "<tr>".$row->$customername1."</td>"; 
        Echo "<td>".$row->PersonID."</td>"; 
        Echo "<td>".$row->Name."</td>"; 
        Echo "<td>".$row->mobile."</td>"; 
        Echo "<td>".$row->email."</td>"; 
        Echo "<td>".$row->dateid."</td></tr>"; 
       } 
       Echo "</table>"; 
       $result->close(); 

        $query_string = "INSERT INTO `restauranttable`(`restname`, `address`, `phoneno`, `colpoints`, `delpoints`) VALUES ('".$restname."','".$restaddress."','".$resthomephone."', 
        '".$restcolpoints."','".$restdelpoints."')"; 
      if ($result = $mysqli -> query($query_string)) { 
       Echo ("Restaurant added"); 
      $result->close(); 
      }else{ 
       echo ("there was an error or there was no query"); 
      } 


     $mysqli->close(); 
?>  
     <p><a href=enterpageuni.php />Back</a></p> 
    </body> 
</html> 

答えて

0

あなたのIF-STATEMENTには終了タグがありません。終了タグの配置場所を確認するには、コードをチェックする必要があります。

if ($result = $mysqli -> query($query_string)) { 
       echo "<table border = '1'>"; 
       echo "<tr><th> Customer Name</th> <th>Order ID</th> <th>Customer ID</th> <th>Restaurant ID</th> <th>Order points</th> <th>Customer Points used</th></tr>"; 
       while ($row = $result -> fetch_object()) { 
        Echo "<tr>".$row->$customername1."</td>"; 
        Echo "<td>".$row->PersonID."</td>"; 
        Echo "<td>".$row->Name."</td>"; 
        Echo "<td>".$row->mobile."</td>"; 
        Echo "<td>".$row->email."</td>"; 
        Echo "<td>".$row->dateid."</td></tr>"; 
       } 
       Echo "</table>"; 
       $result->close(); 
      } //<!--- I'm guessing this where the close tag should go. 
2

あなたのコードブロックの1つに閉じる}がありません。おそらく最初のif ($result = $mysqli -> query($query_string)) {から(おそらく<table>を開きます)PHPはそのコードブロックが閉じられるのを待っているので、ファイルの終わりは「予期しない」です。

関連する問題