Forum Moderators: coopster
Parse error: parse error, unexpected T_ENDIF in /home/home2/ingrawc/public_html/4880/catalog.php on line 70
our code:
<html>
<head>
</head>
<body>
<?
$catid = (integer) $catid;
@ $db = mysql_connect("web6.duc.auburn.edu", "ingrawc", "fluke1" );
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
mysql_select_db("chad");
$sql = "select * from products p,prodcat pc ";
$sql = $sql."where p.productid=pc.productid and pc.catid=$catid";
$result = mysql_query($sql);
$num_results = mysql_num_rows($result);
if($num_results==0)
{echo "There are no products in this category yet";}
else
{
echo "<table width=590>";
for ($i=0; $i<$num_results; $i++)
{$row=mysql_fetch_array($result);}
$productid = stripslashes($row["productid"]);
$thisvalue = stripslashes($row["image"]);
echo "<tr> <td valign=top width=90>";
echo "<a href=bigproduct.php?productid=$productid>";
echo "<img src=$thisvalue align=center height=61 width=85></a><br>";
echo "</td>";
echo "<td valign=top width=90>";
echo "<a href=bigproduct.php?productid=$productid>";
echo "<img src=$thisvalue align=center></a><br>";
echo "</td>";
echo "<td valign=top width=90>";
echo "<a href=bigproduct.php?productid=$productid>";
echo "<img src=$thisvalue align=center></a><br>";
echo "</td>";
echo "</tr>";
$prodname = htmlspecialchar(stripslashes ($row["name"]));
echo "<tr> <td valign=top width=90>";
echo "<a href=bigproduct.php?productid=$productid><b>$prodname</b></a>";
echo "</td>";
echo "</tr>";
$prodprice = htmlspecialchar (stripslashes($row["productprice"]));
echo "<tr> <td valign=top width=90>";
echo "<b>$prodprice</b>";
echo "</td>";
echo "</tr>";
echo "</table>";
endif;
}
?>
</body>
</html>
This code is for an online catalog. anyhelp would be greatly appreciated.
or just remove the "endif;", you don't need it.
you should just drop out of php
?>
and then lose all of the echos, just put in the straight html. when you need to echo this var
$thisvalue
just put it in there like this
<?= $thisvalue?> //<?= is short for echo this var
and keep rolling with the html
put <? ?> around these two lines
$prodname = htmlspecialchar(stripslashes ($row["name"]));
and
$prodprice = htmlspecialchar (stripslashes($row["productprice"]));
and the drop in quickly to php for this
<?
}
?>
and drop the endif, this might work.
if ($this_is_ok) {
$then_do = 'this';
} else {
$do = 'this_other_thing';
} or if ($this_is_ok):
$then_do = 'this';
else:
$do = 'this_other_thing';
endif;
I couldnīt find a if (): corresponding to your endif; anywhere in your code.
Andreas