plintu Posted August 15, 2009 Share Posted August 15, 2009 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: Quote Link to comment Share on other sites More sharing options...
plintu Posted August 15, 2009 Author Share Posted August 15, 2009 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(); ?> Quote Link to comment Share on other sites More sharing options...
shrek1609 Posted August 15, 2009 Share Posted August 15, 2009 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 Quote Link to comment Share on other sites More sharing options...
shrek1609 Posted August 15, 2009 Share Posted August 15, 2009 Re: 2147483647-troubles! i think this will work... $_POST['deposit']=abs((bigint) $_POST['deposit']); again i only think so don't flame me :lol: Quote Link to comment Share on other sites More sharing options...
ShizzleNizzle Posted August 15, 2009 Share Posted August 15, 2009 Re: 2147483647-troubles! I'm pretty sure you have to change *int* to *float*. Quote Link to comment Share on other sites More sharing options...
shrek1609 Posted August 15, 2009 Share Posted August 15, 2009 Re: 2147483647-troubles! last post was wrong try... $_POST['deposit']=abs((int 20) $_POST['deposit']); that should work :-D Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted August 16, 2009 Share Posted August 16, 2009 Re: 2147483647-troubles! last post was wrong try... $_POST['deposit']=abs((int 20) $_POST['deposit']); that should work :-D $_POST['deposit'] = abs(@floatval($_POST['deposit'])); would also work :) Quote Link to comment Share on other sites More sharing options...
CrazyT Posted August 16, 2009 Share Posted August 16, 2009 Re: 2147483647-troubles! so would.. if(isset($_POST['money']) && preg_match("/^\d+$/"ims", $_POST['money'])) { //some code..update money ect. } else { //form box } :D Quote Link to comment Share on other sites More sharing options...
plintu Posted August 18, 2009 Author Share Posted August 18, 2009 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! Quote Link to comment 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.