<分区>
我正在尝试读取存储在 mysql 表中的评论。出于某种原因,我总是在文件的最后一行收到解析错误,即使最后一行是空白也是如此。我不确定它是否相关,但 connect.php 用于将评论放入数据库。我正在使用 wampserver 来托管它并手动编码。
我认为这与 while 循环有关,当我在接近尾声时注释掉 while(){ 和 } 时,正如您所期望的那样,我只是得到了一些缺少变量的错误。我对 php 编码很陌生,所以我很确定问题很简单,我要么错过了,要么没有正确理解。
无论如何,这是我的代码:
<?php
include "connect.php";
?>
<?php
$sql = "SELECT * FROM main";
$result = mysql_query($sql) or die("Could not get posts from table");
while($rows=mysql_fetch_array($result)){
?>
<table bgcolor="green" align="center">
<tr>
<td></td>
</tr>
<tr>
<td><strong> <? echo $rows['name']; ?> </strong></td>
</tr>
<tr>
<td> <? echo $rows['email']; ?> </td>
</tr>
<tr>
<td> <? echo $rows['comment']; ?> </td>
</tr>
</table>
<?
}
?>
感谢您的帮助。 :)