Khashul Posted December 1, 2008 Share Posted December 1, 2008 I'm currently making a game and for some reason can't get the crons right. I'm sure its just something stupid I'm doing and cant see it because i've been sat infront of code for the last few days solidly. The problem is that in a members bank they should gain interest on the amount each time the cron is run. I have set the interest at 3% but cant get it to update each member with money in the bank. <?php session_start(); include("../config.php"); $bankinterest = 0.3; $bankqry = mysql_query("SELECT * FROM members WHERE bank > 0"); while ($member = mysql_fetch_assoc($bankqry)) { $memberid = $member['id']; $bankgain = (floor(100 * ($bankinterest / $member['bank']))) + $member['bank']; mysql_query("UPDATE members SET bank = $bankgain WHERE id = $memberid"); } ?> If anyone can help I would much appreciate that Martin Link to comment https://forums.phpfreaks.com/topic/135009-solved-help-with-cronjob/ Share on other sites More sharing options...
Khashul Posted December 1, 2008 Author Share Posted December 1, 2008 Sorry, I just realised the issue. Clearly was a case of staring too long. This can be closed. Link to comment https://forums.phpfreaks.com/topic/135009-solved-help-with-cronjob/#findComment-703149 Share on other sites More sharing options...
gevans Posted December 1, 2008 Share Posted December 1, 2008 your calculation is wrong (though this isnt why it doesnt work) $bankgain = (floor(100 * ($bankinterest / $member['bank']))) + $member['bank']; //wrong $bankgain = floor((($member['bank']/100) * $bankinterest) + $member['bank']); //right Link to comment https://forums.phpfreaks.com/topic/135009-solved-help-with-cronjob/#findComment-703158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.