Welcome to WebmasterWorld Guest from 54.162.152.232

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

What is wrong with my php?

Parse error: parse error, unexpected T_ENDIF in /home/home2/ingrawc/public_

     
3:40 am on Nov 3, 2002 (gmt 0)

New User

10+ Year Member

joined:Nov 3, 2002
posts:3
votes: 0


we're new to php, so forgive us if this is incredibaly easily.. the error we recieve is:

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.

3:46 am on Nov 3, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 10, 2000
posts:2151
votes: 0


try:
echo "</table>";
}
endif;

I'm not a php programmer by any stretch of the imagination but syntactically speaking I think this should work. You didn't close off the else statement before the endif.

btw - welcome to WebmasterWorld

4:17 am on Nov 3, 2002 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15756
votes: 0


Welcome to WebmasterWorld [webmasterworld.com] frankchad

or just remove the "endif;", you don't need it.

6:40 am on Nov 3, 2002 (gmt 0)

New User

10+ Year Member

joined:Nov 3, 2002
posts:3
votes: 0


we tried it without the endif, it told us it needed one. we got an error saying unexpected $ line 72, without the endif
6:41 am on Nov 3, 2002 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15756
votes: 0


well then there is something else wrong you definitely do not require an endif.

which is line 72?

6:48 am on Nov 3, 2002 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15756
votes: 0


after this line
$thisvalue = stripslashes($row["image"]);

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.

8:04 am on Nov 3, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 22, 2002
posts:1782
votes: 0


You need to be consistent in your use of the if syntax. Use either
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

4:23 pm on Nov 4, 2002 (gmt 0)

New User

10+ Year Member

joined:Nov 3, 2002
posts:3
votes: 0


thank you all so much for the help, i'll try some of this and let you know what happens.....

chad

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members