hex4
hex4

Reputation: 695

PHP - looping a result set

I am going nuts over a script which I've been doing for years now...

The following script executes fine both on my local and on my live shared hosting environment.

BUT

If I add another echo during the "while" loop, the server is giving me a 500 Internal Server Error & I don't have any error_logs :( (and no, on my local it still works fine!!!!)

Any idea why? this looks crazy for me... or I'm just tired now -.-

$select = "SELECT * FROM comments ORDER BY datetime DESC";
$result = mysql_query($select);
if (mysql_num_rows($result)) {
    while ($comment = mysql_fetch_array($result)) {
    ?>
    <tr>
        <td>
            <?php echo $comment["comment_id"]; ?>
        </td>
        <td>
            <?php echo $comment["name"]; ?
        </td>
        <td>
            <?php echo $comment["datetime"]; ?>
        </td>
        <td>
            <?php echo $comment["email"]; ?>
        </td>
        <td>
        </td>
        <td>
        </td>
        <td>
        </td>
        <td>
        </td>
    </tr>
    <?
    } 

}

Upvotes: 0

Views: 128

Answers (1)

Tim Fountain
Tim Fountain

Reputation: 33148

You are missing a > at the end of the <?php echo $comment["name"]; ? line. That's probably the issue if you cut and pasted this code from the problem script. If not - what echo are you adding that causes it to fail?

Upvotes: 3

Related Questions