Web Hosting Talk







View Full Version : kthx...


brcolow
12-04-2002, 05:10 PM
I have this.....
print"<br>You do not have enough gold to buy this item. This item costs $cost gold.";
}
if ($row->user_points > $cost)
{
print"<br>You now own this item";
exit;
}

And iwhen i make it this i get an error in my if statement.. why?

if ($row->user_points < $cost)
}
print"<br>You do not have enough gold to buy this item. This item costs $cost gold.";
}
if ($row->user_points > $cost)
{
print"<br>You now own this item";
exit;
}

Rich2k
12-04-2002, 05:39 PM
Check your syntax. You have one you your curly braces round the wrong way?

Also wouldn't it be more efficient to do

if () {

}
elseif () {

}

rather than two seperate if statements?

brcolow
12-04-2002, 06:01 PM
Nope.. i got this and it gives me an error. IM SURE this is the part of the script thats erroring...

if( $action == 'buy' )
{
print"<table width=\"100%\" cellpadding=\"2\" cellspacing=\"1\" border=\"0\" class=\"forumline\">
<tr>
<th colspan=\"2\" class=\"thCornerL\" height=\"25\" nowrap=\"nowrap\"><p align=\"center\">Item Shop: Buy</p></th>
</tr>
<td class=\"row1\" align=\"left\" valign=\"top\" height=\"100\"><font size=\"1\">Pick which group of items you would like to buy from:<br>| <a href=\"item_shop.php?action=list_weapons\">Weapons</a> | <a href=\"item_shop.php?action=list_armor\">Armor</a> | <a href=\"item_shop.php?action=list_helmets\">Helmets</a> | <a href=\"item_shop.php?action=list_shield\">Shields</a> | <a href=\"item_shop.php?action=list_boots\">Boots</a> |
<a href=\"item_shop.php?action=list_accessories\">Accessories</a> | <br><br><a href=\"item_shop.php\"><center>Go Back to Main</center></a></td>";
exit;
}

if( $action == 'buy_item' )
{
print"You have ";
@ $db = mysql_pconnect("localhost", "", "");
if (!$db)
{

echo "<b>Could not connect to database, try again later.</b>";

exit;

}

mysql_select_db("forums");;
$result = mysql_query("select * from phpbb_users WHERE user_id='$user_id'");
$numrows = mysql_num_rows($result);
if ($numrows > 0)
{
$row = mysql_fetch_object($result);;
print"$row->user_points ";
};
print"gold.<br>";
$id = $_GET['id'];
print"Buy page! ";
print"$cost";
print"$row->user_points";
if ($row->user_points < $cost) {
print"<br>You do not have enough gold to buy this item. This item costs $cost gold.";
}
elseif ($row->user_points < $cost) {
print"<br>You now own this item";
exit;
}

Rich2k
12-04-2002, 07:39 PM
You've got a number of errors in that.

However PHP should give you a line number in the error.

But just to start with

Line 15: put the @ before the function not the variable (but you can remove it... it only is there to supress any errors).

Line 25: Two semi colons

Line 30: Two semi colons

Line 32: Semi colon where there shouldn't be one

I haven't checked the actual validity or logic of what you are trying to do... just the syntax. Try that and if you get an error I'll take a look at the logic.

brcolow
12-04-2002, 11:10 PM
ok that didnt do ANYTHING

brcolow
12-05-2002, 02:24 AM
bump need help....

Rich2k
12-05-2002, 05:28 AM
If you want help you really are going to have to post the ERROR message that PHP gives you. It tells you what's wrong and on what line number!

stephenM
12-05-2002, 05:45 AM
Also you're printing all that HTML using PHP, all those backslashes just make it VERY hard to change if you ever need to and just make it confusing. You can escape from PHP to do large amounts of HTML.

brcolow
12-07-2002, 04:59 PM
I am fine i just need to know whats wrong with that if statment (the error says its on the ?> part meaniong something isnt closed right and when i add that it ****s it up) SO HELP!

grandad
12-07-2002, 05:05 PM
please???

brcolow
12-08-2002, 12:53 AM
please. :)

brcolow
12-08-2002, 01:12 AM
pretty please with sugar