PDA

View Full Version : Parse error



illusions
February 27th, 2003, 07:01 PM
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>

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

Marz
February 28th, 2003, 04:17 PM
<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 :)

illusions
February 28th, 2003, 04:28 PM
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??

illusions
February 28th, 2003, 04:33 PM
hmm.. taht?

Jubba
February 28th, 2003, 05:09 PM
use PHP tags... put (php) before your code and (/php) after your code. But change the ( and ) to [ and ]

illusions
February 28th, 2003, 05:18 PM
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!

Marz
February 28th, 2003, 05:34 PM
;)

Anytime good buddy.. :)

eyezberg
February 28th, 2003, 05:47 PM
For future debugging:
always check the line before the one the error message throws back @ you..

Marz
February 28th, 2003, 06:04 PM
Alognw itht he line it states ;)

Good point eyez.