Jump to content

If statement problem.


iStriide

Recommended Posts

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

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'];

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.