语法错误,意外的文件结束php

时间:2017-08-29 07:31:10

标签: php html

经过研究和调试,我似乎找不到这个错误的原因。



<!doctype html>
<html>
<head>
  <title>hquirit | Home</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="style.css"/>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</head>
<body>
  <?php

    $servername = "localhost";
    $dbuser = "id1147793_hquirit";
    $dbname = "id1147793_bukkitplugins";
    $password = "5mHgq9quirr421";

    $connect = mysqli_connect($servername, $dbuser, $password, $dbname);

    if (!$connect) {
      die("Connection failed: " . mysqli_connect_error());
    }

    $query = "SELECT name, downloads, upload_date FROM bukkit_plugins";
    $result = $connect->query($query);

    echo "<div class='container'>";
    echo "<div class=table-responsive'>";
    echo "<table class='table tabled-bordered table-hover table-condensed'>";
    echo "<thead>";
    echo "<tr>";
    echo "<th>Plugin Name</th><th>Downloads</th><th>Upload Date</th>";
    echo "</tr>";
    echo "</thead>";
    echo "<tbody>";
            if ($result->num_rows > 0) {
              while ($row = $result->fetch_assoc()) {
                echo "<tr>";
                echo "<td>" . $row['name'] . "</td><td>" . $row['downloads'] . "</td><td>" . $row['upload_date'] . "</td>";
                echo "</tr>";
            }
    echo "</tbody>";
    echo "</table>";
    echo "</div>";
    echo "</div>";

  ?>

</body>
</html>
&#13;
&#13;
&#13;

代码的每个部分都有效,所以当我尝试在webhost上查看页面时,出现错误&#34;解析错误:语法错误,/ storage / ssd2 / 793/1147793 / public_html / bukkit_plugins中的文件意外结束第53行&#34; .php出现(第53行是html标签的结尾)。

3 个答案:

答案 0 :(得分:0)

if ($result->num_rows > 0) {
          while ($row = $result->fetch_assoc()) {
            echo "<tr>";
            echo "<td>" . $row['name'] . "</td><td>" . $row['downloads'] . "</td><td>" . $row['upload_date'] . "</td>";
            echo "</tr>";
            }
        }

如果出现了导致错误的原因,你就无法关闭....

答案 1 :(得分:0)

请更改此

echo "<tbody>";
        if ($result->num_rows > 0) {
          while ($row = $result->fetch_assoc()) {
            echo "<tr>";
            echo "<td>" . $row['name'] . "</td><td>" . $row['downloads'] . "</td><td>" . $row['upload_date'] . "</td>";
            echo "</tr>";
        }
echo "</tbody>";



  to  

    echo "<tbody>";
            if ($result->num_rows > 0) {
              while ($row = $result->fetch_assoc()) {
                echo "<tr>";
                echo "<td>" . $row['name'] . "</td><td>" . $row['downloads'] . "</td><td>" . $row['upload_date'] . "</td>";
                echo "</tr>";
              }
            }
    echo "</tbody>";

你刚忘了一个&#34;}&#34;在tbody打印之前。

答案 2 :(得分:0)

Bootstrap需要Tether,因此在包含bootstrap.min.js之前需要包含tether.min.js

尝试在bootstrap.min.js

之前添加这两行

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="https://npmcdn.com/tether@1.2.4/dist/js/tether.min.js"></script>