Jump to content
MakeWebGames

2147483647-troubles!


plintu

Recommended Posts

Ok I already know about big int and int! when my users try to bank money it always prevents them from banking more than 2147483647! I already converted money, bankmoney, and banktransferlogs to bigint(20) and still same problem, I have a basic banking script and it calls for only bankmoney and money! What do you guys think could be the problem? this is driving me nuts! here is the script incase someone wants to look at that:

Link to comment
Share on other sites

Re: 2147483647-troubles!

 

<?php
include "globals.php";
print "<h3>Bank</h3>";
if($ir['frozen'] >0)
{
die("Your bank account has been frozen. Check back in {$ir['frozen']} minutes.");
}
if($ir['bankmoney']>-1)
{
switch($_GET['action'])
{
case "deposit":
deposit();
break;

case "withdraw":
withdraw();
break;

default:
index();
break;
}

}
else
{
if(isset($_GET['buy']))
{
if($ir['money']>20000)
{
print "Congratulations, you bought a bank account for \$20,000!

[url='bank.php']Start using my account[/url]";
$db->query("UPDATE users SET money=money-20000,bankmoney=0 WHERE userid=$userid");
}
else
{
print "You do not have enough money to open an account.
[url='explore.php']Back to town...[/url]";
}
}
else
{
print "Open a bank account today, just \$50,000!

[url='bank.php?buy']> Yes, sign me up![/url]";
}
}
function index()
{
global $db, $ir,$c,$userid,$h;
print "\n[b]You currently have \${$ir['bankmoney']} in the bank.[/b]

At the end of each day, your bank balance will go up by 2%.

<table width='65%' cellspacing=1 class='table'> <tr> <td width='50%'>[b]Deposit Money[/b]

It will cost you 15% of the money you deposit, rounded up. The maximum fee is \$3,000.<form action='bank.php?action=deposit' method='post'>
Amount: <input type='text' name='deposit' value='{$ir['money']}' />

<input type='submit' value='Deposit' /></form></td> <td>
[b]Withdraw Money[/b]

There is no fee on withdrawals.<form action='bank.php?action=withdraw' method='post'>
Amount: <input type='text' name='withdraw' value='{$ir['bankmoney']}' />

<input type='submit' value='Withdraw' /></form></td> </tr> </table>";
}
function deposit()
{
global $db,$ir,$c,$userid,$h;
$_POST['deposit']=abs((int) $_POST['deposit']);
if($_POST['deposit'] > $ir['money'])
{
print "You do not have enough money to deposit this amount.";
}
else
{
$fee=ceil($_POST['deposit']*15/100);
if($fee > 3000) { $fee=3000; }
$gain=$_POST['deposit']-$fee;
$ir['bankmoney']+=$gain;
$db->query("UPDATE users SET bankmoney=bankmoney+$gain, money=money-{$_POST['deposit']} where userid=$userid");
print "You hand over \${$_POST['deposit']} to be deposited, 

after the fee is taken (\$$fee), \$$gain is added to your account. 

[b]You now have \${$ir['bankmoney']} in the bank.[/b]

[url='bank.php']> Back[/url]";
}
}
function withdraw()
{
global $db,$ir,$c,$userid,$h;
$_POST['withdraw']=abs((int) $_POST['withdraw']);
if($_POST['withdraw'] > $ir['bankmoney'])
{
print "You do not have enough banked money to withdraw this amount.";
}
else
{

$gain=$_POST['withdraw'];
$ir['bankmoney']-=$gain;
$db->query("UPDATE users SET bankmoney=bankmoney-$gain, money=money+$gain where userid=$userid");
print "You ask to withdraw $gain, 

the banking lady grudgingly hands it over. 

[b]You now have \${$ir['bankmoney']} in the bank.[/b]

[url='bank.php']> Back[/url]";
}
}
$h->endpage();
?>
Link to comment
Share on other sites

Re: 2147483647-troubles!

not 100% sure but i think

$_POST['deposit']=abs((int) $_POST['deposit']);

will max out the amount to deposit to 2.147 billion

can they deposit twice say 2 bill then another 2 bill ?

 

also try manually inserting say 5billion into the bank field in the database that will give you an idea where the fault is... if you can manually add it then problem is script side

Link to comment
Share on other sites

Re: 2147483647-troubles!

Man I been so busy I forgot to come back here!!! The (int) was the bug I want to thank all of you guys so much I was ripping my hair out over here!!! I always used abs((int)) but I never researched it much I just figured it was absolute integer! did think about the int connection to the database! thank you soo much!

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...