skooda Posted January 16, 2012 Share Posted January 16, 2012 Ok I keep getting this error the rest of my crons work but this one just keep giving me an error well heres my cron_day file <?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("UPDATE `users` SET `daily`='0'"); $db->query("UPDATE users SET reward_done=0"); $db->query("UPDATE `users` SET `restorevip`='0'"); $db->query("UPDATE `users` SET `restore`='0'"); $db->query("UPDATE `users` SET `restoredd`='0'"); $db->query("UPDATE users SET ddcollections = 5 WHERE donatordays >= 1"); $db->query("UPDATE users SET ddcollections = 3 WHERE donatordays = 0"); $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 vipdays=vipdays-1 WHERE vipdays > 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("UPDATE users SET turns=25"); $db->query("TRUNCATE TABLE rating"); $db->query("TRUNCATE TABLE votes;"); ?> and heres the error that keep poping up when I do it. QUERY ERROR: Unknown column 'restore' in 'field list' Query was UPDATE `users` SET `restore`='0' Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted January 16, 2012 Share Posted January 16, 2012 Well somehow the users table doesn't contain the field restore. BTW this cron is simply horrible, why not set all the fields in one shot instead of using multiple queries? Where did you took this script (if it's the original McCode one, then I must admit it's really not good). Quote Link to comment Share on other sites More sharing options...
skooda Posted January 16, 2012 Author Share Posted January 16, 2012 O so how do put them in one field Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted January 16, 2012 Share Posted January 16, 2012 not in one field but in one query ;) But that would not fix your field issue, you should really check if you need that row 30 of yours. To make multiple set in one query (for example): $db->query("UPDATE users SET daily='0', reward_done=0, restorevip='0', restoredd='0'"); You can also make something quicker above for your fedjail: $db->query("UPDATE users SET fedjail=0 WHERE userid IN (SELECT fed_userid FROM fedjail WHERE fed_days=0)"); In that case you don't need any ifs, no need to read all and store in an array before, and at the end it will be even faster ;) there is others which could be cleaned up as well maybe, but I let you dig. Quote Link to comment Share on other sites More sharing options...
skooda Posted January 16, 2012 Author Share Posted January 16, 2012 ok thanks alot I will get on it right now Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted January 16, 2012 Share Posted January 16, 2012 but again that doesn't solve your issue with the missing field on the table, and therefore your error will stay. Quote Link to comment Share on other sites More sharing options...
skooda Posted January 16, 2012 Author Share Posted January 16, 2012 so my cron day want work Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted January 16, 2012 Share Posted January 16, 2012 well either remove the restore=0 from your daily cron or add that field on the users table... easy. Yet before doing one or the other you should wonder why you need it / if you need it. Quote Link to comment Share on other sites More sharing options...
skooda Posted January 16, 2012 Author Share Posted January 16, 2012 well I really dont know a guy did it for me a while back and it was working I just never pick off of it until now Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted January 16, 2012 Share Posted January 16, 2012 Well I think you just have a huge mix of different things... which may not even mix nicely ;) Time for you to learn SQL and... PHP maybe. Quote Link to comment Share on other sites More sharing options...
skooda Posted January 16, 2012 Author Share Posted January 16, 2012 I know php and I try understand sql but thats confusing Quote Link to comment Share on other sites More sharing options...
skooda Posted January 16, 2012 Author Share Posted January 16, 2012 ok I found the problem 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.