Jump to content


Photo

Internet Game - Transfering Help


  • Please log in to reply
3 replies to this topic

#1 spike_132000

spike_132000
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 14 June 2006 - 02:43 PM

Hey There, I have this code. it is for my internet game - [a href=\"http://undergroundwarz.samwillis.net\" target=\"_blank\"]http://undergroundwarz.samwillis.net[/a]. I am having problems when i try to use it, what it is supposed to do is, take money from one persons's bank and put it into another, like transfering money between two accounts! Here is the code for "bank4.php"

<?
include 'connect.php';
session_start();
?>
<link rel="stylesheet" href="style.css">
<?
if (isset($_SESSION['player'])) 
{

$player=$_SESSION['player'];

$ide=$_POST['id'];
$userstats="SELECT * from km_users where playername='$player'";
$userstats2=mysql_query($userstats) or die("Could not get user stats");
$userstats3=mysql_fetch_array($userstats2);
$tuserstats="SELECT * from km_users where ID='ide'";
$tuserstats2=mysql_query($tuserstats) or die("Could not get other players stats");
$tuserstats3=mysql_fetch_array($tuserstats2);
$gold1=$_POST['gold'];
if ($userstats3[bank]>$gold)
{
$updatebanks="update km_users set gold=gold-'$gold1' where playername='$player'";
$updateother="update km_users set gold=gold+'$gold1' where ID='$ide'";
mysql_query($updatebanks) or die("Could not Update You");
mysql_query($updateother) or die("Could not Update Player");
print "<center>Successfully Transfered $gold gold to $ide.<br>Click <a href='index.php'>here</a> to return";
}
else if ($userstats3[bank]<$gold)
{
print "<center>You do not have that amount of gold to Transfer";
}
else if ($gold=='-')
{
print "<center>You cannot transfer negative amounts";
}
}
else
{
print "<center>You are not logged in"; die();
} 
?>

Would Someone be able to tell me where I am going wrong... Here is the code from "bank.php" that sends the data to "bank4.php"

print "<form action='bank4.php' method='post'>ID to Send To: <input type='text' name='id'> Amount to Send: <input type='text' name='id'><input type='submit' value='Transfer Cash'></form>";

Thank You in Advance!

#2 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 14 June 2006 - 02:45 PM

what exactly is the problem, what is it not doing or what is it doing incorrectly?
z..z..z..z..z..z..z..z..

#3 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 14 June 2006 - 04:41 PM

for starters before i even look at the rest of your code,
print "<form action='bank4.php' method='post'>ID to Send To: <input type='text' name='id'> Amount to Send: <input type='text' name='id'><input type='submit' value='Transfer Cash'></form>";
both your input tags have the same name.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 14 June 2006 - 04:46 PM

You might also want to learn to catch errors. The code you have is error prone simply because you never check any queries actualy worked before trying to use your results.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users