Hey guys. I am very new to this. For some reason I get this error and I'm not sure why. Please advise. "Parse error: syntax error, unexpected $end in /home/booksfor/public_html/index.php on line 121"

<?php
require_once("conn.php");
require_once("includes.php");

$q1 = "select * from class_categories order by CategoryName";
$r1 = mysql_query($q1) or die(mysql_error());

while($a1 = mysql_fetch_array($r1))
{
	$MyID[] = $a1[CategoryID];
	$MyName[] = $a1[CategoryName];

$q2 = "select count(*) from class_catalog where CategoryID = '$a1[CategoryID]'  ";
$r2 = mysql_query($q2) or die(mysql_error());
$a2 = mysql_fetch_array($r2);

$MyNumber[] = $a2[0];

e;


if(!empty($MyID));
{
	for($i = '0'; $i <= (count($MyID)); $i+=2)
	{
		$one = $i;
		$two = $i + 1;


	$categories .= "<tr>\n\t\t";

	if(!empty($MyID[$one])) 
	{
		$categories .= "<td width=216><a href=\"search.php?c=$MyID[$one]\" class=BlueLink>$MyName[$one] ($MyNumber[$one])</a></td>\n\t\t";
	}
	else
	{
		$categories .= "<td width=216></td>\n\t\t";
	}

	if(!empty($MyID[$two])) 
	{
		$categories .= "<td width=216><a href=\"search.php?c=$MyID[$two]\" class=BlueLink>$MyName[$two] ($MyNumber[$two])</a></td>\n\t\t";
	}
	else
	{
		$categories .= "<td width=216></td>\n\t\t";
	}

}
}

//get the featured listings

$q1 = "select * from class_catalog, class_categories where class_catalog.CategoryID = class_categories.CategoryID and class_catalog.FeaturedStatus = '1' order by rand() limit 0,4";
$r1 = mysql_query($q1) or die(mysql_error());

if(mysql_num_rows($r1) > '0')
{
	$FeaturedAds .= "<table align=center width=431><tr>\n\t<td colspan=5><BR><BR><strong><font size=4 face=Verdana, Arial, Helvetica, sans-serif>Featured Listings</font></strong><BR><P></td>\n</tr>\n\n<tr>\n\t";

while($a1 = mysql_fetch_array($r1))
{
	$al++;

	if($al == '1')
	{
		$align = "align=center";
	}
	elseif($al == '2')
	{
		$align = "align=center";
	}
	else
	{
		$align = "align=center";
	}

	$FeaturedAds .= "<td valign=\"top\" width=100 align=center>\n\n\t\t";

	$FeaturedAds .= "<table width=100 cellspacing=0 border=1 bordercolor=DCDCDC rules=rows>\n\t\t<tr>\n\t\t";

	if(!empty($a1[images]))
	{
		$ShowImage = explode("|", $a1[images]);
		$FeaturedAds .= "<td width=100 align=center valign=top><div align=\"center\"><img src=\"images/$ShowImage[0]\" width=100 height=96></div></td>\n\t\t</tr>\n\t\t<tr>\n\t\t <td height=\"50\" align=center valign=top align=center valign=top bgcolor=\"#E9E9E9\"><div align=\"center\"><a class=BlackLink href=\"info.php?id=$a1[ProductID]\">$a1[ProductName]</a></div></td>\n\t\t</tr>\n\t\t";
	}
	else
	{
		$FeaturedAds .= "<td width=100 align=center valign=top><div align=\"center\"><img src=\"images/nopic.gif\" width=100 height=96></div></td>\n\t\t</tr>\n\t\t<tr>\n\t\t <td height=\"50\" align=center valign=top align=center valign=top bgcolor=\"#E9E9E9\"><div align=\"center\"><a class=BlackLink href=\"info.php?id=$a1[ProductID]\">$a1[ProductName]</a></div></td>\n\t\t</tr>\n\t\t";
	}

	$FeaturedAds .= "</table>\n\n\t";

	$FeaturedAds .= "</td>\n\n\t";

	$fa++;
}

for($fe = '1'; $fe <= (5 - $fa); $fe++)
{
[B]line 121.[/B]		$FeaturedAds .= "<td width=100>&nbsp;</td>\n\t";
	}

$FeaturedAds .= "</tr>\n\n";

$FeaturedAds .= "<tr>\n\t<td colspan=2 align=center valign=top height=5></td>\n</tr>\n</table>\n\n";
}


//$banners .= "<table align=center width=650 cellspacing=0 cellpadding=0 border=0>\n<tr>\n\t";


//get the templates
require_once("templates/HeaderIndex.php");
require_once("templates/IndexTemplate.php");
require_once("templates/FooterTemplate.php");

?>php

    Three things:

    • In the future, please place [php ] [/code] tags around your code: it will highlight it in pretty colors, which help readability.

    • Somewhere around line 20 you have a line with e;, which doesn't make sense

    • You never close the while {} loop which you start at the beginning of the code, which probably is the cuprit

    edit:

    4th: You end the code with ?>php

    Unless you want to see php, remove php at the end

      Thanks for the help. I found the error and corrected it. The site is set up so I can go into an admin area and add more categories to my index.php but for some reason that stopped working. If you want to look at http://www.booksforbuckeyes.com
      you can see where I am talking about. If you have any suggestions about that, it would be great. If not, I appreciate your help in solving the error.

        sorry, site takes ages to load ;-)

        If you have a genuine problem: please open a thread for it. Else, please mark this thread resolved

          Write a Reply...