Reecey12345 Posted March 1, 2014 Share Posted March 1, 2014 For some weird reason, my cron day started to fail i entered some coding from a mod into it first and it was entered correctly but somehow started to fail, i removed it and put the original file in to see if my cron day will still work. It executes but still, donator days dont increase, lucky boxes cant be opened & Fedjailers days aint decreasing, so yes it isn't working. Any tips to fixing this? I can't go for a fresh reinstall, i have done hell of alot in my game now, got active members & donators, but an error like this they aint happy with and ive put my effort into fixing it and dont know what else to do as i cant know for sure until it executes yet again. All help appreciated. Quote Link to comment Share on other sites More sharing options...
jcvenom Posted March 1, 2014 Share Posted March 1, 2014 For some weird reason, my cron day started to fail i entered some coding from a mod into it first and it was entered correctly but somehow started to fail, i removed it and put the original file in to see if my cron day will still work. It executes but still, donator days dont increase, lucky boxes cant be opened & Fedjailers days aint decreasing, so yes it isn't working. Any tips to fixing this? I can't go for a fresh reinstall, i have done hell of alot in my game now, got active members & donators, but an error like this they aint happy with and ive put my effort into fixing it and dont know what else to do as i cant know for sure until it executes yet again. All help appreciated. run the cron manually and see what error its shows must likley your missing a { or } somewhere post the cron code here Quote Link to comment Share on other sites More sharing options...
peterisgb Posted March 1, 2014 Share Posted March 1, 2014 Stick up the code. Quote Link to comment Share on other sites More sharing options...
Reecey12345 Posted March 1, 2014 Author Share Posted March 1, 2014 (edited) <?php include "config.php"; global $_CONFIG; if($_GET['code'] != $_CONFIG['code']) { die(""); } define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; $db->query("UPDATE fedjail set fed_days=fed_days-1"); $q=$db->query("SELECT * FROM fedjail WHERE fed_days=0"); $ids=array(); while($r=$db->fetch_row($q)) { $ids[]=$r['fed_userid']; } if(count($ids) > 0) { $db->query("UPDATE users SET fedjail=0 WHERE userid IN(".implode(",", $ids).")"); } $db->query("DELETE FROM fedjail WHERE fed_days=0"); $db->query("UPDATE users SET daysingang=daysingang+1 WHERE gang > 0"); $db->query("UPDATE users SET daysold=daysold+1, boxes_opened=0"); $db->query("UPDATE users SET mailban=mailban-1 WHERE mailban > 0"); $db->query("UPDATE users SET donatordays=donatordays-1 WHERE donatordays > 0"); $db->query("UPDATE users SET cdays=cdays-1 WHERE course > 0"); $db->query("UPDATE users SET bankmoney=bankmoney+(bankmoney/50) where bankmoney>0"); $db->query("UPDATE users SET cybermoney=cybermoney+(cybermoney/100*7) where cybermoney>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;"); ?> - - - Updated - - - Looking at that im guessing i need a } at the end before ?>, i already added this and ran it again, nothing worked Edited March 1, 2014 by KyleMassacre Added php tags Quote Link to comment Share on other sites More sharing options...
jcvenom Posted March 1, 2014 Share Posted March 1, 2014 <?php include "config.php"; global $_CONFIG; if($_GET['code'] != $_CONFIG['code']) { die(""); } define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; $db->query("UPDATE fedjail set fed_days=fed_days-1"); $q=$db->query("SELECT * FROM fedjail WHERE fed_days=0"); $ids=array(); while($r=$db->fetch_row($q)) { $ids[]=$r['fed_userid']; } if(count($ids) > 0) { $db->query("UPDATE users SET fedjail=0 WHERE userid IN(".implode(",", $ids).")"); } $db->query("DELETE FROM fedjail WHERE fed_days=0"); $db->query("UPDATE users SET daysingang=daysingang+1 WHERE gang > 0"); $db->query("UPDATE users SET daysold=daysold+1, boxes_opened=0"); $db->query("UPDATE users SET mailban=mailban-1 WHERE mailban > 0"); $db->query("UPDATE users SET donatordays=donatordays-1 WHERE donatordays > 0"); $db->query("UPDATE users SET cdays=cdays-1 WHERE course > 0"); $db->query("UPDATE users SET bankmoney=bankmoney+(bankmoney/50) where bankmoney>0"); $db->query("UPDATE users SET cybermoney=cybermoney+(cybermoney/100*7) where cybermoney>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;"); ?> - - - Updated - - - Looking at that im guessing i need a } at the end before ?>, i already added this and ran it again, nothing worked where about is the code you entered for the mod Quote Link to comment Share on other sites More sharing options...
Reecey12345 Posted March 1, 2014 Author Share Posted March 1, 2014 I deleted it, as i said i have entered the original file, and it still doesnt work Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted March 1, 2014 Share Posted March 1, 2014 We'll we need to see where the script is failing at. You probably have some sort of error that's a bit hard to catch with the naked eye. Try turning on error_reporting(), maybe try adding at the end of all your queries or die(mysql_error()); before your ";" for the queries, and go to: yourdomain.com/daily_cron.php?code=<insert your code here> and tell us if you get any errors Quote Link to comment Share on other sites More sharing options...
jcvenom Posted March 1, 2014 Share Posted March 1, 2014 We'll we need to see where the script is failing at. You probably have some sort of error that's a bit hard to catch with the naked eye. Try turning on error_reporting(), maybe try adding at the end of all your queries or die(mysql_error()); before your ";" for the queries, and go to: yourdomain.com/daily_cron.php?code=<insert your code here> and tell us if you get any errors Couldnt find any errors try what kyle said its definitely some sort of code break Quote Link to comment Share on other sites More sharing options...
Reecey12345 Posted March 1, 2014 Author Share Posted March 1, 2014 The cron no longer shows it is failing as i stated in the first post, it was when i put the part in for my mod so put in the normal cron day. And before i used the other the cron worked perfectly fine, now it doesn't what so ever. Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted March 1, 2014 Share Posted March 1, 2014 Did you try what I said??? Did you turn on error_reporting()??? Did you add or die(mysql_error());??? Are you adding the correct code at the end of the URL for the cron??? All these things are the common tasks that need to be done in order to troubleshoot. PHP is not just going to not work and leave you with no explanation why it didn't work. You just got to tell it what to do Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted March 1, 2014 Share Posted March 1, 2014 Did you try what I said??? Did you turn on error_reporting()??? Did you add or die(mysql_error());??? Are you adding the correct code at the end of the URL for the cron??? All these things are the common tasks that need to be done in order to troubleshoot. PHP is not just going to not work and leave you with no explanation why it didn't work. You just got to tell it what to do You've clearly never used output buffer handling then :P Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted March 1, 2014 Share Posted March 1, 2014 Testing and fully working: <?php include(__DIR__ . '/config.php'); global $_CONFIG; if(!array_key_exists('code', $_GET) || $_GET['code'] != $_CONFIG['code']) exit; define("MONO_ON", 1); require(__DIR__ . '/class/class_db_'.$_CONFIG['driver'].'.php'); $db = new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c = $db->connection_id; include(__DIR__ . '/global_funcs.php'); $db->query("UPDATE `fedjail` SET `fed_days` = `fed_days` - 1"); $q = $db->query("SELECT * FROM `fedjail` WHERE `fed_days` = 0"); $ids = array(); while($r = $db->fetch_row($q)) array_push($ids, $r['fed_userid']); if(count($ids) > 0) $db->query("UPDATE users SET fedjail=0 WHERE userid IN(".implode(",", $ids).")"); $db->query("DELETE FROM `fedjail` WHERE `fed_days` = 0"); $db->query("UPDATE `users` SET " . "`daysingang` = IF(`gang` > 0, `daysingang` + 1, 0), " . "`daysold` = `daysold` + 1, " . "`boxes_opened` = 0, " . "`mailban` = IF(`mailban` > 0, `mailban` - 1, 0), " . "`donatordays` = IF(`donatordays` > 0, `donatordays` - 1, 0), " . "`cdays` = IF(`course` > 0, `cdays` - 1, 0), " . "`bankmoney` = IF(`bankmoney` > 0, `bankmoney` + (`bankmoney` * .2), 0) " . "`cybermoney` + IF(`cybermoney` > 0, (`cybermoney` * 0.7), 0)" ); $q = $db->query("SELECT `userid`, `course` FROM `users` WHERE `cdays` = 0 AND `course` > 0"); while($r = $db->fetch_row($q)) { $db->query("INSERT INTO `coursesdone` VALUES(".$r['userid'].", ".$r['course'].")"); $cd = $db->query("SELECT * FROM `courses` WHERE `crID` = ".$r['course']); if($db->num_rows($cd)) { $coud = $db->fetch_row($cd); $upd = ""; $ev = ""; if($coud['crSTR']) { $upd .= ", `strength` = `strength` + ".$coud['crSTR']; $ev .= ", ".number_format($coud['crSTR'])." strength"; } if($coud['crGUARD']) { $upd .= ", `guard` = `guard` + ".$coud['crGUARD']; $ev .= ", ".number_format($coud['crGUARD'])." guard"; } if($coud['crLABOUR']) { $upd .= ", `labour` = `labour` + ".$coud['crLABOUR']; $ev .= ", ".number_format($coud['crLABOUR'])." labour"; } if($coud['crAGIL']) { $upd .= ", `agility` = `agility` + ".$coud['crAGIL']; $ev .= ", ".number_format($coud['crAGIL'])." agility"; } if($coud['crIQ']) { $upd .= ", `IQ` = `IQ` + ".$coud['crIQ']; $ev .= ", ".number_format($coud['crIQ'])." IQ"; } $ev = substr($ev, 1); if($upd) $db->query("UPDATE userstats SET `userid` = `userid` ".$upd." WHERE `userid` = ".$r['userid']); event_add($r['userid'], "Congratulations, you completed the ".$coud['crNAME']." and gained ".$ev."!"); } else event_add($r['userid'], "Unfortunately, the course you were taking was removed from the School's curriculum. Your course has been ended at no extra cost to you"); } $db->query("UPDATE `users` SET `course` = 0 WHERE `cdays` = 0"); $db->query("TRUNCATE TABLE `votes`"); PHP: 5.4 Apache: 2.4.7 SQL: 5.6 Quote Link to comment Share on other sites More sharing options...
Reecey12345 Posted March 1, 2014 Author Share Posted March 1, 2014 Dude, i have tried so many things, i have had it working in the past until i added the mod, then it stopped working so i put the old cron file back in that usually works and now it doesnt work, i have no errors when i go to cronday Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted March 2, 2014 Share Posted March 2, 2014 Dude, i have tried so many things, i have had it working in the past until i added the mod, then it stopped working so i put the old cron file back in that usually works and now it doesnt work, i have no errors when i go to cronday Use the file I have provided. Upload it to your webroot. Make sure the job is scheduled in your crontab 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.