spike_132000 Posted June 14, 2006 Share Posted June 14, 2006 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"[code]<?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();} ?>[/code]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"[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>";[/code]Thank You in Advance! Quote Link to comment https://forums.phpfreaks.com/topic/11983-internet-game-transfering-help/ Share on other sites More sharing options...
joquius Posted June 14, 2006 Share Posted June 14, 2006 what exactly is the problem, what is it not doing or what is it doing incorrectly? Quote Link to comment https://forums.phpfreaks.com/topic/11983-internet-game-transfering-help/#findComment-45564 Share on other sites More sharing options...
.josh Posted June 14, 2006 Share Posted June 14, 2006 for starters before i even look at the rest of your code,[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>";[/code]both your input tags have the same name. Quote Link to comment https://forums.phpfreaks.com/topic/11983-internet-game-transfering-help/#findComment-45614 Share on other sites More sharing options...
trq Posted June 14, 2006 Share Posted June 14, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/11983-internet-game-transfering-help/#findComment-45616 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.