homepage Welcome to WebmasterWorld Guest from 54.196.159.11
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
What is wrong with my php?
Parse error: parse error, unexpected T_ENDIF in /home/home2/ingrawc/public_
frankchad




msg:1275804
 3:40 am on Nov 3, 2002 (gmt 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.

 

oilman




msg:1275805
 3:46 am on Nov 3, 2002 (gmt 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

jatar_k




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

Welcome to WebmasterWorld [webmasterworld.com] frankchad

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

frankchad




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

we tried it without the endif, it told us it needed one. we got an error saying unexpected $ line 72, without the endif

jatar_k




msg:1275808
 6:41 am on Nov 3, 2002 (gmt 0)

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

which is line 72?

jatar_k




msg:1275809
 6:48 am on Nov 3, 2002 (gmt 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.

andreasfriedrich




msg:1275810
 8:04 am on Nov 3, 2002 (gmt 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

frankchad




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

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

chad

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved