Jump to content

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

?>

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.