php parse error always on the last line

Posted by is0lated on Stack Overflow See other posts from Stack Overflow or by is0lated
Published on 2010-02-05T14:21:00Z Indexed on 2010/12/27 18:54 UTC
Read the original article Hit count: 194

Filed under:
|
|

I'm trying to read a comment that is stored in a mysql table. For some reason I always get a parse error on the last line of the file even if the last line is blank. I'm not sure if it's relevant but the connect.php works for putting the comment into the database. I'm using wampserver to host it and coding it by hand.

I think that's it's something to do with the while loop, when I comment out the while(){ and the } near the end I just get a few missing variable errors as you would expect. I'm quite new to php coding so I'm pretty sure the problem will be something simple that I've either missed or not understood properly.

Anyway, here's my code:

<?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>
<?
}
?>

Thanks for the help. :)

© Stack Overflow or respective owner

Related posts about php

Related posts about wampserver