grlayouts Posted January 29, 2007 Share Posted January 29, 2007 ok i have my own online game, when people bank it updates the database ie bank=bank+(ammount)I want it up update by 0.03 percent or so every hour for interest.the script i have is[code]<?include('config.php');error_reporting(E_ALL) ; ini_set('display_errors', 1);mysql_query('UPDATE `players` SET `BANK` = `BANK` + (`BANK` * '.rand(1.01, 1.02).'), `interest` = `interest` (`bank` * '.rand(1.01, 1.02).')');?>[/code]but its not working.. any ideas? Quote Link to comment Share on other sites More sharing options...
rantsh Posted January 29, 2007 Share Posted January 29, 2007 can you provide an example printout of your query? ??? Quote Link to comment Share on other sites More sharing options...
grlayouts Posted January 29, 2007 Author Share Posted January 29, 2007 it completes but doesnt not work. Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted January 29, 2007 Share Posted January 29, 2007 Could be me, but it seems like you're missing an operator:[code]`interest` = `interest` (`bank` * '.rand(1.01, 1.02).')[/code]Shouldn't that be:[code]`interest` = `interest` + (`bank` * '.rand(1.01, 1.02).')[/code] Quote Link to comment Share on other sites More sharing options...
paul2463 Posted January 29, 2007 Share Posted January 29, 2007 yes you are missing a maths function in your querylook at you your query, especially the part about interest, for maths to work it needs operators ( * / = etc)interest = interest ( !!!missing operator!!!) (bank * rand) Quote Link to comment Share on other sites More sharing options...
grlayouts Posted January 29, 2007 Author Share Posted January 29, 2007 yeah i see that.. but even the bank one is not working.. Quote Link to comment Share on other sites More sharing options...
paul2463 Posted January 29, 2007 Share Posted January 29, 2007 ok then, try setting the rand(1.01, 1.02) as a variable first[code]<?phpinclude('config.php');error_reporting(E_ALL) ; ini_set('display_errors', 1);$interest = rand(1.01, 1.02);mysql_query("UPDATE `players` SET `BANK` = `BANK` + (`BANK` * '$interest'), `interest` = `interest` + (`BANK` * '$interest')") or die ("Cannot Update Table". mysql_error());?>[/code] Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 29, 2007 Share Posted January 29, 2007 Off topic, but why are you giving random amount of interest? If my bank did that, I'd get kind of annoyed. Quote Link to comment Share on other sites More sharing options...
grlayouts Posted January 29, 2007 Author Share Posted January 29, 2007 i have no idea.. i did have a good reason but now no idea.. :D Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 29, 2007 Share Posted January 29, 2007 You could do it on a scale. The more money they have, the more interest they get. So 1-1000 gets 1%, 1000-5000 gets 1.5%, etc. Quote Link to comment Share on other sites More sharing options...
grlayouts Posted January 29, 2007 Author Share Posted January 29, 2007 i could if i knew how.. :) 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.