athena26 Posted March 13, 2021 Share Posted March 13, 2021 Having a issue with education this shows ...You are currently doing the Foundation Mathematics, you have -21 days remaining -21 days. Quote Link to comment Share on other sites More sharing options...
Veramys Posted March 14, 2021 Share Posted March 14, 2021 Sounds like there's an error in the cron for ending the class when the days reach 0 Quote Link to comment Share on other sites More sharing options...
athena26 Posted March 14, 2021 Author Share Posted March 14, 2021 How do I fix this . What can I do to fix this should I post my education.php in here and the cron I'm using ? Quote Link to comment Share on other sites More sharing options...
Spydre452 Posted March 14, 2021 Share Posted March 14, 2021 3 hours ago, athena26 said: How do I fix this . What can I do to fix this should I post my education.php in here and the cron I'm using ? It would be helpful, yea or supply the necessary/relevant lines of code.. Do you have a globals file running for education that handles the data or is this all done in crons, you need to make sure a DELETE FROM or something appropriate is actioned when the education time hits zero or is equal to current time Pm me if you need any assistance Quote Link to comment Share on other sites More sharing options...
athena26 Posted March 14, 2021 Author Share Posted March 14, 2021 ok here the education.php that i have i got it from here in the forums ,,, <?php /* This is free work of Razor42! Do not try to re-sell this! */ include "globals.php"; print "<h3>Schooling</h3>"; if($ir['course'] > 0) { $cd=$db->query("SELECT * FROM courses WHERE crID={$ir['course']}"); $coud=$db->fetch_row($cd); print "You are currently doing the {$coud['crNAME']}, you have {$ir['cdays']} days remaining."; } else { if($_GET['cstart']) { $_GET['cstart'] = abs((int) $_GET['cstart']); //Verify. $cd=$db->query("SELECT * FROM courses WHERE crID={$_GET['cstart']}"); if($db->num_rows($cd) == 0) { print "You are trying to start a non-existant course!"; } else { $coud=$db->fetch_row($cd); $cdo=$db->query("SELECT * FROM coursesdone WHERE userid=$userid AND courseid={$_GET['cstart']}"); if($ir['money'] < $coud['crCOST']) { print "You don't have enough money to start this course."; $h->endpage(); exit; } if($ir['level'] < $coud['crLEVEL']) { print "Your don't have the required level to start this course."; $h->endpage(); exit; } if($db->num_rows($cdo) > 0) { print "You have already done this course."; $h->endpage(); exit; } $db->query("UPDATE users SET course={$_GET['cstart']},cdays={$coud['crDAYS']},money=money-{$coud['crCOST']} WHERE userid=$userid"); print "You have started the {$coud['crNAME']}, it will take {$coud['crDAYS']} days to complete."; } } else { //list courses print "Here is a list of available courses."; $q=$db->query("SELECT * FROM courses"); print "<br /><table width=75% cellspacing=1 class='table'><tr style='background:gray;'><th>Course</th><th>Description</th><th>Cost</th><th>Level</th><th>Take</th></tr>"; while($r=$db->fetch_row($q)) { $cdo=$db->query("SELECT * FROM coursesdone WHERE userid=$userid AND courseid={$r['crID']}"); if($db->num_rows($cdo)) { $do="<i>Done</i>"; } else { $do="<a href='education.php?cstart={$r['crID']}'>Take</a>"; } print "<tr><td>{$r['crNAME']}</td><td>{$r['crDESC']}</td><td>\${$r['crCOST']}</td><td>{$r['crLEVEL']}</td><td>$do</td></tr>"; } print "</table>"; } } $h->endpage(); ?> and the cron that is currently running on this education file is $db->query("UPDATE users SET cdays=cdays-1 WHERE course > 0"); $q=$db->query("SELECT * FROM users WHERE cdays=0 AND course > 0"); while($r=$db->fetch_row($q)) { $cd=$db->query("SELECT * FROM courses WHERE crID={$r['course']}"); $coud=$db->fetch_row($cd); $userid=$r['userid']; $db->query("INSERT INTO coursesdone VALUES({$r['userid']},{$r['course']})"); $upd=""; $ev=""; if($coud['crSTR'] > 0) { $upd.=",us.strength=us.strength+{$coud['crSTR']}"; $ev.=", {$coud['crSTR']} strength"; } if($coud['crGUARD'] > 0) { $upd.=",us.guard=us.guard+{$coud['crGUARD']}"; $ev.=", {$coud['crGUARD']} guard"; } if($coud['crLABOUR'] > 0) { $upd.=",us.labour=us.labour+{$coud['crLABOUR']}"; $ev.=", {$coud['crLABOUR']} labour"; } if($coud['crAGIL'] > 0) { $upd.=",us.agility=us.agility+{$coud['crAGIL']}"; $ev.=", {$coud['crAGIL']} agility"; } if($coud['crIQ'] > 0) { $upd.=",us.IQ=us.IQ+{$coud['crIQ']}"; $ev.=", {$coud['crIQ']} IQ"; } $ev=substr($ev,1); if ($upd) { $db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET us.userid=us.userid $upd WHERE u.userid=$userid"); } $db->query("INSERT INTO events VALUES('',$userid,unix_timestamp(),0,'Congratulations, you completed the {$coud['crNAME']} and gained $ev!')"); } $db->query("UPDATE users SET course=0 WHERE cdays=0"); $db->query("TRUNCATE TABLE votes;"); ?> Quote Link to comment Share on other sites More sharing options...
Sim Posted March 16, 2021 Share Posted March 16, 2021 (edited) Thats very odd. -21days. I dont see how it got to -21days. Once at 0 days it should delete course according to code. But $db->query("TRUNCATE TABLE votes;"); y is thus here in education cron? Edited March 16, 2021 by Sim Quote Link to comment Share on other sites More sharing options...
athena26 Posted March 16, 2021 Author Share Posted March 16, 2021 Hmm I wasn't sure why it went to - days as the code seems fine to me I also have another issue the level issue my experience gets stuck at level 165 and experience is a 999999999 it won't allow me to level to level 166 Quote Link to comment Share on other sites More sharing options...
Sim Posted March 16, 2021 Share Posted March 16, 2021 What is the exp field? Int(9) change it to int(11) 1 Quote Link to comment Share on other sites More sharing options...
Veramys Posted March 18, 2021 Share Posted March 18, 2021 On 3/15/2021 at 10:03 PM, Sim said: Thats very odd. -21days. I dont see how it got to -21days. Once at 0 days it should delete course according to code. But $db->query("TRUNCATE TABLE votes;"); y is thus here in education cron? That's in that cron file because that's base mccodes day cron. So it truncates votes daily. 1 Quote Link to comment Share on other sites More sharing options...
athena26 Posted March 19, 2021 Author Share Posted March 19, 2021 Since I upgraded my servers my Crons has now stopped working again I'm having major issues as a new coder it's difficult but still trying to understand it Quote Link to comment Share on other sites More sharing options...
Fabionuno Posted March 22, 2021 Share Posted March 22, 2021 It would probably be easier if you just used timestamps instead im very new at coding too i tried mccodes and was a pain there is timestamps for mccodes somewhere on mkg id take a look at it 😉 i mean its good to learn but it would make your life eadier:) Like his Quote Link to comment Share on other sites More sharing options...
athena26 Posted April 14, 2021 Author Share Posted April 14, 2021 I still ain't able to fix this problem. Quote Link to comment Share on other sites More sharing options...
newttster Posted April 14, 2021 Share Posted April 14, 2021 Which part ... the crons or the -21 days? Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted April 14, 2021 Share Posted April 14, 2021 Change $q=$db->query("SELECT * FROM users WHERE cdays=0 AND course > 0"); to $q=$db->query("SELECT * FROM users WHERE cdays <= 0 AND course > 0"); 1 Quote Link to comment Share on other sites More sharing options...
PHPStudent Posted April 14, 2021 Share Posted April 14, 2021 MagicTallGuy knows Mccodes like back of his hand. 😄 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.