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>
system
February 28, 2003, 9:17pm
2
<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
system
February 28, 2003, 9:28pm
3
Thanx!
Yeah, it’s better when using “coding rules”
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??
system
February 28, 2003, 10:09pm
5
use PHP tags… put (php) before your code and (/php) after your code. But change the ( and ) to [ and ]
system
February 28, 2003, 10:18pm
6
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!
system
February 28, 2003, 10:47pm
8
For future debugging:
always check the line before the one the error message throws back @ you…
system
February 28, 2003, 11:04pm
9
Alognw itht he line it states
Good point eyez.