Parse error

I get this error… And I can’t find out what’s wrong…

Parse error: parse error, unexpected ‘;’ in g:\apache\www\guestbook.php on line 44

Here’s the code where the error is. (the table line is 37, error in 44, but the “;” can’t be the error… or?)
<br>

<table bgcolor="#AAAAAA" border=“0” Width=“75%” cellspacing=“1” cellpadding=“2”><br>
<?php<br>
$query = “SELECT * FROM guestbook ORDER BY date_auto”;<br>
$result = mysql_query($query, $connection);
<p> for ($i = 0; $i < mysql_num_rows($result); $i++)<br>
(<br>
$name = mysql_result($result, $i, “name”); //Line 44 <br>
$email = mysql_result($result, $i, “email”);<br>
$email_len = strlen($email);<br>
$comment = mysql_result($result, $i, “comment”);<br>
$date = mysql_result($result, $i, “date_auto”);<br>
$show_date = date(“H:i:s d/m/y”, $date);</p>
<p> echo ‘<tr><td bgcolor="#EEEEEE"><br>
<font> face=“verdana” size=“2”>’;<br>
if ($email > 0)<br>
{<br>
echo ‘<b>Name:</b> <a href="mailto:’ . $email . ‘">’
. $name . ‘</a>’;<br>
}<br>
else<br>
{<br>
echo ‘<b>Name:</b> ‘. $name;<br>
}<br>
echo ‘<br>
<br><br>
<b>Comment:</b> ’ . $comment .’</font><br>
<td><br>
<td widht=“1%” valign=“top” nowrap bgcolor="#EEEEEE"><br>
<font><br>
<b>Date: </b>’ . $show_date .’<br>
</font><br>
</td><br>
</tr><br>
';<br>
)<br>
?><br>
</table>


<table bgcolor="#AAAAAA" border="0" Width="75%" cellspacing="1" cellpadding="2">

<?php

$query = "SELECT * FROM guestbook ORDER BY date_auto";

$result = mysql_query($query, $connection);


for ($i = 0; $i < mysql_num_rows($result); $i++)
{
   $name = mysql_result($result, $i, "name"); //Line 44 
   $email = mysql_result($result, $i, "email");
   $email_len = strlen($email);
   $comment = mysql_result($result, $i, "comment");
   $date = mysql_result($result, $i, "date_auto");
   $show_date = date("H:i:s d/m/y", $date);

   echo '<tr><td bgcolor="#EEEEEE"><font> face="verdana" size="2">';

   if ($email > 0)
   {
      echo '<b>Name:</b> <a href="mailto:' . $email . '">' . $name . '</a>';
   }
   else
   {
      echo '<b>Name:</b> '. $name;
   }

   echo '<br> <b>Comment:</b> ' . $comment .'</font><td><td width="1%" valign="top" nowrap bgcolor="#EEEEEE">';
   echo '<font><b>Date: </b>' . $show_date .'</font></td></tr>';
}
?>
</table>

Okay man… I fixed her up for you… And I even added a little bit of management code wise… I think the first tutorial I’m going to create is how to write good looking code… :)… It’s alot easier to debug this way huh? hehe…

The main problem was… After your for loop you had a ( instead of { be careful about that buddy :slight_smile:

Thanx!

Yeah, it’s better when using “coding rules” :slight_smile:

The code don’t look like taht here, it just became like that when I pasted it,

btw, how did ya make it look like taht??

hmm… taht?

use PHP tags… put (php) before your code and (/php) after your code. But change the ( and ) to [ and ]

hmm, let me try that out


<table bgcolor="#AAAAAA" border="0" Width="75%" cellspacing="1" cellpadding="2">

<?php

$query = "SELECT * FROM guestbook ORDER BY date_auto";

$result = mysql_query($query, $connection);

yeah, looks good!

Thanx!

:wink:

Anytime good buddy… :slight_smile:

For future debugging:
always check the line before the one the error message throws back @ you…

Alognw itht he line it states :wink:

Good point eyez.