confused over parse error message

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dai
Forum Newbie
Posts: 16
Joined: Wed May 15, 2002 6:12 am

confused over parse error message

Post by Dai »

I'm using edit plus for php at the moment and I keep getting this message
Parse error: parse error in C:\apache\htdocs\php_practice\table_test.php on line 12 (echo "<tr>\n";)
with the following script:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> table test</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
</HEAD>
<BODY>
<?php
echo "<table border=\"1\" bordercolor=#FFFF00 align=center>\"n;
for($i=1; $i<=6; $i++)
{
echo "<tr>\n";
for($j=0; $j<=3; $i++)
{
echo "\t<td>";
echo ($i * $j);
echo "</td>\n";
}
echo "</tr>\n";
}
echo "</table>";
?>
</BODY>
</HTML>

I've wriiten another one similar to the above one which works fine with no error message and has the exact coding it has the same code for line 12. So why the error for line 12 (echo "<tr>\n";)
the other script:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Nested Table Loops</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
</HEAD>
<BODY bgcolor=#0033FF>
<BR><BR><BR><BR>
<?php
echo "<table border=\"1\"bordercolor=#FFFF00 align=center cellspacing=3>\n";
for($y=1; $y<=18; $y++)
{
echo "<tr>\n";
for($x=1; $x<=18; $x++)
{
echo "\t<td bgcolor=#FFFF99 align=center>";
echo ($x * $y);
echo "</td>\n";
}
echo "</tr>\n";
}
echo "</table>";
?>
</BODY>
</HTML>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Parse errors are generally not generated by the line cited in the error message but by a line before. In this case it is this line:

Code: Select all

echo "<table border="1" bordercolor=#FFFF00 align=center>"n;
where you have a closing double quote and then an n after. Try,

Code: Select all

echo "<table border="1" bordercolor=#FFFF00 align=center>\n";
Mac
Post Reply