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

?>

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.