Jump to content
MakeWebGames

A small cron problem


War_Hero
 Share

Recommended Posts

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

Link to comment
Share on other sites

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 (=).

Link to comment
Share on other sites

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.

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.

 Share

×
×
  • Create New...