War_Hero Posted August 17, 2008 Share Posted August 17, 2008 Hi all. I've been having a little trouble with a new cron for a while now. It's for an investment mod a friend and I made. In the mod, the user can upgrade their contract with the investment company from level 0 to level 1, which gives more interest per day. My problem is that even if a user is at Level 1, they still receive 3.0% interest on their investment, instead of the 5.5% they're supposed to get at Level 1. Here is what I have in my cron_day.php: if($ir['investlevel'] == 1) { $db->query("UPDATE users SET userBANKAMMT = userBANKAMMT + (userBANKAMMT/100*5.5) WHERE userBANKAMMT > 0"); } elseif($ir['investlevel'] == 0) { $db->query("UPDATE users SET userBANKAMMT = userBANKAMMT + (userBANKAMMT/100*3.0) WHERE userBANKAMMT > 0"); } I've tried different variations of the cron to get it to work. For example, I tried: $db->query("UPDATE users SET userBANKAMMT = userBANKAMMT + (userBANKAMMT/100*3.0) WHERE userBANKAMMT > 0 AND investlevel == 0"); $db->query("UPDATE users SET userBANKAMMT = userBANKAMMT + (userBANKAMMT/100*5.5) WHERE userBANKAMMT > 0 AND investlevel == 1"); but that didn't work either. :( So I'm a bit confused as to how to get this cron to work. I am still a newbie coder so I'm still learning. :) Any help will be highly appreciated. :) Quote Link to comment Share on other sites More sharing options...
Floydian Posted August 18, 2008 Share Posted August 18, 2008 Re: A small cron problem Instead of $db->query("UPDATE users SET userBANKAMMT = userBANKAMMT + (userBANKAMMT/100*3.0) WHERE userBANKAMMT > 0 AND investlevel == 0"); $db->query("UPDATE users SET userBANKAMMT = userBANKAMMT + (userBANKAMMT/100*5.5) WHERE userBANKAMMT > 0 AND investlevel == 1"); try $db->query("UPDATE users SET userBANKAMMT = userBANKAMMT + (userBANKAMMT/100*3.0) WHERE userBANKAMMT > 0 AND investlevel = 0"); $db->query("UPDATE users SET userBANKAMMT = userBANKAMMT + (userBANKAMMT/100*5.5) WHERE userBANKAMMT > 0 AND investlevel = 1"); It's just 1 equal sign in mysql comparison statements. mysql has the assignment operator which is also used for comparison (=). Quote Link to comment Share on other sites More sharing options...
War_Hero Posted August 18, 2008 Author Share Posted August 18, 2008 Re: A small cron problem Right. :) Thank you. I'll try that and hopefully at 00:00 BST I'll get the correct amount of interest. :) I'll make sure I only use one (=) in my crons from now on. Fortunately, I haven't needed to have (=) signs in any of my crons for the mods I've made so far, so this is lesson learned. :) Thank you. Quote Link to comment Share on other sites More sharing options...
Floydian Posted August 18, 2008 Share Posted August 18, 2008 Re: A small cron problem Glad I could help ;) Quote Link to comment Share on other sites More sharing options...
War_Hero Posted August 18, 2008 Author Share Posted August 18, 2008 Re: A small cron problem Just turned 12am here and went to have a look in my investment bank.....and I received the correct amount of interest. Thank you for helping me. :) :) :) 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.