script is pulling more then they have....
Posted on
16th Feb 2014 07:03 pm by
admin
I have this script for my game where they can change there race. This will cost them 2,500 points. However in our database points are called crystals.
If the person has 500 points, and the script takes 2,500 it will put them at -2,000 points. I need the script to tell them they dont have enough points and then not change there race because they dont have enough to do so. However im not to sure on how I would write it.
This is the race change script im editing, can anyone explain how to write this to do what I need:
Code: function conf_race_change()
{
global $ir,$c,$userid,$h;
if($ir['race'] == "Pirate") { $r="Ninja"; } else { $r="Pirate"; }
print "Switching your race will cost 2,500 points. Are you sure you want to become a $r?<br />
<a href='preferences.php?action=racechange2'>Yes</a> | <a href='preferences.php'>No</a>";
}
function do_race_change()
{
global $db,$ir,$c,$userid,$h;
if($ir['race'] == "Pirate") { $r="Ninja"; } else { $r="Pirate"; }
$db->query("UPDATE users SET race='$r' WHERE userid=$userid");
$db->query("UPDATE users SET crystals=crystals-2500 WHERE userid=$userid");
print "Success, you are now $r!<br />
<a href='preferences.php'>Back</a>";
}
No comments posted yet
Your Answer:
Login to answer
64
25
Other forums
Take info from one coloum and move to another
Hi all,
I have this:
Code: [Select]$array = "SELECT stock_id FROM stocks WHERE stock_
downloading a file as HTML
Hi.
I'm rather confused with forcing a download. I just want to save dynamic content (from $_SESS
PHP Session Issue
I'm having an issue with one section on my website dealing with sessions. Now I know that myself and
problem with query error
First Thanks to those who helped me on my previous posts, and the following code i'm using is not mi
file_put_contents and createimagefromjpeg
All,
I do somethings and then I have the following code:
file_put_contents('./test/'.$filename
printing links
Hi every1
i am connecting to a table in sql and the looping through with a while ($ var = my
Limiting checkboxes?
Hi guys,
I have this code: Code: if(isset($_POST['selected'])) {
foreach($_POST['selec
Values disappear from my array :( HELP!
hey all, I have a lil mysql/php/apache script that queries a database
and pulls put 5 integers.
Hardcopy printing is to wide
I want to make a hardcopy at runtime of my active form like this
Help with PHP Email Script
Hi guys,
I'm a newbie to php and need help with the script below:
At the moment when I