PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Im making a game and well i came across a few problems all in one i want to make it where it will check to see if the user has enough gold or money to buy the armor or if i can make it where the radio button will only show when thet user has the same or more money or gold. then make it where it changes the armor, attack, and defense in database. here is my script
<?php
require 'db.php';
$shield = $_POST['shield'];
$leatherhelmet = $_POST['leatherhelmet'];
$bodyguard = $_POST['bodyguard'];
$steelarmor = $_POST['steelarmor'];
$gold = $_GET['gold'];
if (($shield) > ($gold)) {
echo '<center><font size="1" face="tahoma" color="red"><b>Error!</b> Sorry You dont got the Gold for this Armor.</font></center><br>';
require 'armorshop.php';
return;
}
if (($letherhelmet) > ($gold)) {
echo '<center><font size="1" face="tahoma" color="red"><b>Error!</b> Sorry You dont got the Gold for this Armor.</font></center><br>';
require 'armorshop.php';
return;
}
if (($bodyguard) > ($gold)) {
echo '<center><font size="1" face="tahoma" color="red"><b>Error!</b> Sorry You dont got the Gold for this Armor.</font></center><br>';
require 'armorshop.php';
return;
}
if ((steelarmor) > ($gold)) {
echo '<center><font size="1" face="tahoma" color="red"><b>Error!</b> Sorry You dont got the Gold for this Armor.</font></center><br>';
require 'armorshop.php';
return;
}
if ((!$shield) || (!$leatherhelmet) || (!$bodyguard) || (!$steelarmor)) {
echo '<center><font size="1" face="tahoma" color="red"><b>Error!</b> Sorry you dont have enough gold for this armor</font></center><br>';
require 'armorshop.php';
return;
}
$sql = mysql_query("INSERT INTO users (armor)
VALUES('$armor')") or die (mysql_error());
if (!$sql) {
echo '<center><font class="h">There has been an error adding your armor. Please contact the webmaster.</font></center>';
}
?>
well it just keeps sending back that i dont got enough gold for the armor and it doesnt update the armor and the defense (not on there still working on that part) or the attack (not on there still working on that part) and well im not sure on them parts and im not sure on how to make it subtrack how much the armor cost either i mean i know how but im not sure on making it more then one thing and changing the price and stuff
the POST ones are to get the infomation from armorshop.php
and the GET is to get the Gold from the database to check to see how much the user has so it can check to see if they have enough to use to buy the armor and so it can get subtracted...
Smackie wrote:the POST ones are to get the infomation from armorshop.php
and the GET is to get the Gold from the database to check to see how much the user has so it can check to see if they have enough to use to buy the armor and so it can get subtracted...
its fine about the post ones.
where do you get the gold value from the db???why do you use a GET? I dont see any url variables being used
im getting the gold from users database but i just put that script together im looking for someone that can help me to design it better and make everything work like its suppose to and stuff.. I havent really put a game together so thats why im asking for some help right now
if ((!$shield) || (!$leatherhelmet) || (!$bodyguard) || (!$steelarmor)) {
echo '<center><font size="1" face="tahoma" color="red"><b>Error!</b> Sorry you dont have enough gold for this armor</font></center><br>';
require 'armorshop.php';
return;
}
if ((!$shield) || (!$leatherhelmet) || (!$bodyguard) || (!$steelarmor)) {
echo '<center><font size="1" face="tahoma" color="red"><b>Error!</b> Sorry you dont have enough gold for this armor</font></center><br>';
require 'armorshop.php';
return;
}
i already fixed the spelling before you said anything... and also i dont really see a problem there unless you mean with the ! (!$shield)