Task -> Update Age
Niki Offline
Junior Member
**
Posts: 29
Joined: Oct 2016
Post: #1
Task -> Update Age
I run an rpg forum which means automatic aging is a nice thing to have.

I’ve followed this freebie to a t (meaning I’ve installed everything as how it’s shown here): http://rpg-directory.com/showthread.php?tid=86759

Anytime I try to manually run the task for testing purposes (I have it set up to run every minute) I get an SQL error and essentially this thing doesn’t work at all.

Error attached in screenshot.

If anyone knows what the issue could be please let me know because this is frustrating and I’ve not been able to get ahold of the original creator of this for a while. .


Attached File(s) Thumbnail(s)
   
(This post was last modified: 12-26-2017 03:44 AM by Niki.)
12-26-2017 03:40 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #2
RE: Task -> Update Age
The table named set twice on the task query. Also, it seems that there is something wrong with your code near to the UPDATE.

(This post was last modified: 12-26-2017 04:17 AM by RateU.)
12-26-2017 03:56 AM
Find all posts by this user Quote this message in a reply
Niki Offline
Junior Member
**
Posts: 29
Joined: Oct 2016
Post: #3
RE: Task -> Update Age
I figured out that it was incorrect table wise as it is not mybb_ it's actually mybbsc_ for my database.

Here is the full code:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 <?php
/**
* Author: Shinka
* Description: Task that, when ran, automatically adjusts all characters' ages
* based on current age, registration date, and current date.
*/

function task_age($task)
{
global $mybb, $db;

/**
* INCREMENT AMOUNT
* Amount to increment age by.
* Can be integer (e.g. 1) or float (e.g. 0.5).
*/
$INCREMENT = 0.5;

/**
* UPDATE AGE
* Replace "fid18" with the ID of your custom profile field.
* If your age field only allows whole numbers, change "DECIMAL(11, 2)" to "UNSIGNED".
*/
$query = $db->query("
   UPDATE mybbsc_userfields userfields
   SET fid2 = CAST(fid2 as DECIMAL(100, 1)) + {$INCREMENT};
");

add_task_log($task, "The age characters task successfully ran.");
}


I'm also noticing that the regular expression for the profile field will not recognize 0 (as if filled in on the profile as 0 it will not show up, just acts as if it doesn't even exist? which is weird and then also won't update with the task).

Changed "DECIMAL(11, 2)" to "DECIMAL(100, 1)" so that there was more room for numbers before the decimal and only one number after the decimal.

I originally did not want decimals at all, just whole increments and tried to follow the tutorial for that, however when replacing "DECIMAL(100, 1)" with "UNSIGNED" it shows up as another SQL error like that is completely incorrect variable? I'm wondering if maybe this script is just certainly too buggy or incorrect to use?

Example with "DECIMAL(100, 1)" changed to "UNSIGNED" :

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 <?php
/**
* Author: Shinka
* Description: Task that, when ran, automatically adjusts all characters' ages
* based on current age, registration date, and current date.
*/

function task_age($task)
{
global $mybb, $db;

/**
* INCREMENT AMOUNT
* Amount to increment age by.
* Can be integer (e.g. 1) or float (e.g. 0.5).
*/
$INCREMENT = 1;

/**
* UPDATE AGE
* Replace "fid18" with the ID of your custom profile field.
* If your age field only allows whole numbers, change "DECIMAL(11, 2)" to "UNSIGNED".
*/
$query = $db->query("
   UPDATE mybbsc_userfields userfields
   SET fid2 = CAST(fid2 as UNSIGNED) + {$INCREMENT};
");

add_task_log($task, "The age characters task successfully ran.");
}

12-26-2017 06:36 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #4
RE: Task -> Update Age
(12-26-2017 06:36 AM)Niki Wrote:  I originally did not want decimals at all, just whole increments and tried to follow the tutorial for that, however when replacing "DECIMAL(100, 1)" with "UNSIGNED" it shows up as another SQL error like that is completely incorrect variable?

What error you get?

12-29-2017 01:26 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: