iStriide Posted August 7, 2011 Share Posted August 7, 2011 One of my if statements is that i'm trying to make it where somebody can't buy a duplicate of an item, but for some reason it doesn't work. <?php $find_multiple = "SELECT * FROM `weapons` WHERE `Username` = '$session'"; $dup = mysql_fetch_array(mysql_query($find_multiple)) or trigger_error(mysql_error()); $weapon_name_check = $dup['Weapon_Name']; if($weapon_name_check == $weapon_name){ header("Location: http://www.halobattles.comyr.com/weaponshop.php"); //header expects a full URI. Location must be capitalized, and a space must be after the colon. This will insure that it works across ALL browsers. }elseif($weapon_cost > $player_Credits){ header("Location: http://www.halobattles.comyr.com/weaponshop.php"); //see above. }else{ ?> Link to comment https://forums.phpfreaks.com/topic/244101-if-statement-problem/ Share on other sites More sharing options...
trq Posted August 7, 2011 Share Posted August 7, 2011 Where is $weapon_name defined? Also, why aren't you simply querying the database for this? Link to comment https://forums.phpfreaks.com/topic/244101-if-statement-problem/#findComment-1253617 Share on other sites More sharing options...
iStriide Posted August 7, 2011 Author Share Posted August 7, 2011 Where is $weapon_name defined? Also, why aren't you simply querying the database for this? This is nere the top of my code. <?php $session = $_SESSION['user']; $w = (isset($_GET['w'])) ? (int)$_GET['w'] : 0; //0 being default weapon. $find = "SELECT * FROM `weapon_shop` WHERE `id` = '$w'"; $run = mysql_fetch_array(mysql_query($find)) or trigger_error(mysql_error()); $weapon_id = $run['id']; $weapon_name = $run['Weapon_Name']; ?> Link to comment https://forums.phpfreaks.com/topic/244101-if-statement-problem/#findComment-1253618 Share on other sites More sharing options...
trq Posted August 7, 2011 Share Posted August 7, 2011 Your going to have to start debugging. I'd start by echoing $weapon_name_check and $weapon_name and see if they do indeed contain what you think. How do you even know it's not working? And again I ask, why aren't you doing these checks in a query? Link to comment https://forums.phpfreaks.com/topic/244101-if-statement-problem/#findComment-1253622 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.