R1der Posted October 11, 2006 Share Posted October 11, 2006 [code]<?if(!$_GET['stp']){?><b>Welcome to the gem exchange.<br><a href="gexchange.php?stp=ene">Exchange 5 gems for 100 energy</a><br><?}elseif($_GET['stp']==ene){if($user['uGems']== "<4"){echo "You Dont have enough gems for this exchange."; exit;}else{echo "You exchanged 5 gems into 100 energy";$db->query("UPDATE users SET uAttackTurns=uAttackTurns+'100' , uGems=uGems-'5' WHERE uID='" . $user['uID'] . "'");}}?>[/code]Basicly the exchange does fine but it dont stop them from exchanging gems even when thay go into minus.can anyone help with this problem?Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/23678-whats-wrong-with-this-code/ Share on other sites More sharing options...
HuggieBear Posted October 11, 2006 Share Posted October 11, 2006 Your syntax is slightly wrong, try this...[code]<?phpif(!$_GET['stp']){?><b>Welcome to the gem exchange.<br><a href="gexchange.php?stp=ene">Exchange 5 gems for 100 energy</a><br><?php}elseif($_GET['stp'] == "ene"){if($user['uGems'] <= 4){echo "You Dont have enough gems for this exchange."; exit;}else{echo "You exchanged 5 gems into 100 energy";$db->query("UPDATE users SET uAttackTurns=uAttackTurns+'100' , uGems=uGems-'5' WHERE uID='" . $user['uID'] . "'");}}?>[/code]When checking a string, use double quotes, so [code=php:0]if $var == "string"[/code] you had no quotesWhen comparing numbers, no need for the quotes so [code=php:0]if $var <= 4[/code] you had the 4 in quotes along with the less than sign.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/23678-whats-wrong-with-this-code/#findComment-107464 Share on other sites More sharing options...
R1der Posted October 11, 2006 Author Share Posted October 11, 2006 Wow that worked greatThanks Quote Link to comment https://forums.phpfreaks.com/topic/23678-whats-wrong-with-this-code/#findComment-107466 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.