castle Posted November 28, 2008 Share Posted November 28, 2008 I am getting this in my day cron file, can't figure out why: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/content/m/o/b/mobsterworld/html/cron_day.php on line 43 this is line 43: $coud=mysql_fetch_row($cd); This is my day cron (changing to mysql_ works where the db-> does not) <?php include "config.php"; include "mysql.php"; mysql_query("UPDATE fedjail set fed_days=fed_days-1"); $q=mysql_query("SELECT * FROM fedjail WHERE fed_days=0"); $ids=array(); while($r=mysql_fetch_row($q)) { $ids[]=$r['fed_userid']; } if(count($ids) > 0) { mysql_query("UPDATE users SET fedjail=0 WHERE userid IN(".implode(",", $ids).")"); } mysql_query("DELETE FROM fedjail WHERE fed_days=0"); mysql_query("UPDATE users SET daysingang=daysingang+1 WHERE gang > 0"); mysql_query("UPDATE users SET daysold=daysold+1, boxes_opened=0"); mysql_query("UPDATE users SET mailban=mailban-1 WHERE mailban > 0"); mysql_query("UPDATE users SET donatordays=donatordays-1 WHERE donatordays > 0"); mysql_query("UPDATE users SET cdays=cdays-1 WHERE course > 0"); mysql_query("UPDATE users SET turns=25"); mysql_query("UPDATE users SET bankmoney=bankmoney+(bankmoney/50) where bankmoney>0"); mysql_query("UPDATE users SET cybermoney=cybermoney+(cybermoney/100*7) where cybermoney>0"); mysql_query("UPDATE users SET lotterycap=10",$c); mysql_query("UPDATE mod_slots SET Tokens = 75"); mysql_query("UPDATE users SET rates=1"); mysql_query("UPDATE users SET reward_done=0"); mysql_query("DELETE FROM mail WHERE mail_time < (unix_timestamp() -2592000)",$c); mysql_query("UPDATE users SET userCONTRACT = userCONTRACT - 1 WHERE userCONTRACT > 0"); mysql_query("UPDATE users SET userBANKAMMT = userBANKAMMT + (userBANKAMMT/100*5.5) WHERE userBANKAMMT > 0 AND investlevel = 1"); mysql_query("UPDATE users SET userBANKAMMT = userBANKAMMT + (userBANKAMMT/100*3.0) WHERE userBANKAMMT > 0 AND investlevel = 0"); mysql_query("UPDATE users SET userBANKAMMT = userBANKAMMT + (userBANKAMMT/100*7.2) WHERE userBANKAMMT > 0 AND investlevel = 2"); mysql_query("UPDATE users SET userDAYS = userDAYS - 1 WHERE userDAYS != 0"); mysql_query("UPDATE users SET happiness=happiness-1 WHERE married != 0"); mysql_query("UPDATE users SET tired=0"); mysql_query("UPDATE users SET daysmarried=daysmarried+1 WHERE married !=0"); $q=mysql_query("SELECT * FROM users WHERE cdays=0 AND course > 0"); while($r=mysql_fetch_row($q)) { $cd=mysql_query("SELECT * FROM courses WHERE crID={$r['course']}"); $coud=mysql_fetch_row($cd); $userid=$r['userid']; mysql_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) { mysql_query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET us.userid=us.userid $upd WHERE u.userid=$userid"); } mysql_query("INSERT INTO events VALUES('',$userid,unix_timestamp(),0,'Congratulations, you completed the {$coud['crNAME']} and gained $ev!')"); } mysql_query("UPDATE users SET course=0 WHERE cdays=0"); mysql_query("TRUNCATE TABLE votes;"); ?> Quote Link to comment Share on other sites More sharing options...
radio_active Posted November 28, 2008 Share Posted November 28, 2008 Re: day cron error $cd=mysql_query("SELECT * FROM courses WHERE crID={$r['course']}"); $coud=mysql_fetch_row($cd); Try replace that with this. $well = {$r['course']}; $cd = sprintf("SELECT * FROM `courses`` WHERE crID` = %d",$well); $that = mysql_fetch_array($cd); for it to be more secure (if it works for V1) or just simply change the row => array. (just replace those two lines with the ones below) $cd=mysql_query("SELECT * FROM courses WHERE crID={$r['course']}"); $coud=mysql_fetch_array($cd); EDIT: Forgot code tags Quote Link to comment Share on other sites More sharing options...
castle Posted November 28, 2008 Author Share Posted November 28, 2008 Re: day cron error This worked minus the { $well = $r['course']; $cd = sprintf("SELECT * FROM `courses`` WHERE crID` = %d",$well); $that = mysql_fetch_array($cd); thanks Quote Link to comment Share on other sites More sharing options...
radio_active Posted November 29, 2008 Share Posted November 29, 2008 Re: day cron error Glad i could help ;) Quote Link to comment Share on other sites More sharing options...
radio_active Posted November 29, 2008 Share Posted November 29, 2008 Re: day cron error No wait, you will have to change $that to $coud as the $coud variable is being called later in the script, woops. Change that. Quote Link to comment Share on other sites More sharing options...
POG1 Posted November 29, 2008 Share Posted November 29, 2008 Re: day cron error This could do with tome optimization. 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.