解析错误:语法错误,第90行意外的文件结束

时间:2014-03-25 05:36:16

标签: php

我正在学习php,现在它已经被错误阻止了两天"解析错误:语法错误,第90行的意外文件结束"。我检查了原因,发现它可能来自一个未关闭的标签{,(,",'但是当我确认我发现一切正常时。我已经删除了所有行并逐行编写代码,但最后我发现了同样的错误。在某些时候我认为它来自包含的文件,但它在包含它的其他文件中运行良好。 你能帮我找一下错误!!

<?php
 include 'forum_include.php';
 doDB();

 //gather the topics
 $get_topics_sql = "SELECT topic_id, topic_title,
 DATE_FORMAT(topic_create_time, '%b %e %Y at %r') AS
 fmt_topic_create_time, topic_owner FROM forum_topics
 ORDER BY topic_create_time DESC";
 $get_topics_res = mysqli_query($mysqli, $get_topics_sql)
 or die(mysqli_error($mysqli));

 if (mysqli_num_rows($get_topics_res) < 1) {
 //there are no topics, so say so
 $display_block = "<p><em>No topics exist.</em></p>";
} else {
 //create the display string
 $display_block = <<<END_OF_TEXT
 <table>
 <tr>
 <th>TOPIC TITLE</th>
 <th># of POSTS</th>
 </tr>
END_OF_TEXT;

 while ($topic_info = mysqli_fetch_array($get_topics_res)) {
 $topic_id = $topic_info[topic_id];
 $topic_title = stripslashes($topic_info[topic_title]);
 $topic_create_time = $topic_info[fmt_topic_create_time];
 $topic_owner = stripslashes($topic_info[topic_owner]);

 //get number of posts
 $get_num_posts_sql = "SELECT COUNT(post_id) AS post_count FROM
 forum_posts WHERE topic_id = '".$topic_id."'";
 $get_num_posts_res = mysqli_query($mysqli, $get_num_posts_sql)
 or die(mysqli_error($mysqli));

 while ($posts_info = mysqli_fetch_array($get_num_posts_res)) {
 $num_posts = $posts_info[post_count];
 }

 //add to display
 $display_block .= <<<END_OF_TEXT
 <tr>
 <td><a href="forum_showtopic.php?topic_id=$topic_id">
 <strong>$topic_title</strong></a><br/>
 Created on $topic_create_time by $topic_owner</td>
 <td class="num_posts_col">$num_posts</td>
 </tr>
 END_OF_TEXT;
 }
 //free results
 mysqli_free_result($get_topics_res);
 mysqli_free_result($get_num_posts_res);

 //close connection to MySQL
 mysqli_close($mysqli);

 //close up the table
 $display_block .= "</table>";
 }
 ?>
 <!DOCTYPE html>
<html>
 <head>
 <title>Topics in My Forum</title>
 <style type="text/css">
 table {
 border: 1px solid black;
 border-collapse: collapse;
 }
 th {
 border: 1px solid black;
 padding: 6px;
 font-weight: bold;
 background: #ccc;
 }
 td {
 border: 1px solid black;
 padding: 6px;
 }
 .num_posts_col { text-align: center; }
 </style>
 </head>
 <body>
 <h1>Topics in My Forum</h1>
 <?php echo $display_block; ?>
<p>Would you like to <a href="forum_addtopic.html">add a topic</a>?</p>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

你的第二个heredoc的结尾在它前面有一个空间。

END_OF_TEXT;

删除空格,以便PHP将其识别为heredoc的结尾。