acidpunk Posted September 16, 2012 Share Posted September 16, 2012 One of my cron jobs, running 2 lines of code, out of nowhere just 'stopped' working? my site has many people on it, and this cron is one of the most important parts of the website.. I just don't know how/why it could stop working, and then not fix (i've tried everything.) original bit of code that just 'stopped' mysql_query("UPDATE dead_mobs SET timeleft=timeleft-'1'"); mysql_query("DELETE FROM dead_mobs WHERE timeleft<='0'"); lol! like i said... the most simple script running. just died, and WILL NOT fix..... Quote Link to comment Share on other sites More sharing options...
Psycho Posted September 16, 2012 Share Posted September 16, 2012 Have you tried even the most basic of debugging? There is no way for us to tell you why it is not running. You should run the same code directly and see what errors are returned $query = "UPDATE dead_mobs SET timeleft=timeleft-'1'"; echo "Running Query: {$query}<br>\n": $result = mysql_query($query); if(!$result) { echo "Error: " . mysql_error(); } else { echo "Affected Rows: " . mysql_affected_rows(); } $query = "DELETE FROM dead_mobs WHERE timeleft<='0'"; echo "<br><br>Running Query: {$query}<br>\n": $result = mysql_query($query); if(!$result) { echo "Error: " . mysql_error(); } else { echo "Affected Rows: " . mysql_affected_rows(); } However, looking at your queries, I think you are simply taking the wrong approach. You should not need to delete records based upon timeleft < 0. Your queries for extracting records you want should simply ignore records where timeleft < 0. And, reducing timeleft by -1 may also not be needed. Quote Link to comment Share on other sites More sharing options...
acidpunk Posted September 16, 2012 Author Share Posted September 16, 2012 Hmm, i tried running that, it brought back an error, and weirdly... this script just started working again out of nowhere. It starts if i'm running more then 2 queries in this script.. Can you guide me into a better way of doing this? Quote Link to comment Share on other sites More sharing options...
acidpunk Posted September 16, 2012 Author Share Posted September 16, 2012 also, it only does timeleft-1 because during the time where timeleft is above 0, this will not be displayed. and when it hits <=0 it will be displayed again. Quote Link to comment Share on other sites More sharing options...
acidpunk Posted September 16, 2012 Author Share Posted September 16, 2012 and yes, btw i did do a check, it brought back nothing Quote Link to comment Share on other sites More sharing options...
hakimserwa Posted September 16, 2012 Share Posted September 16, 2012 is here any error msgs? Quote Link to comment Share on other sites More sharing options...
Psycho Posted September 16, 2012 Share Posted September 16, 2012 Hmm, i tried running that, it brought back an error and yes, btw i did do a check, it brought back nothing You seem to be contradicting yourself. If there was an error - what was it? We are not mind readers so please share with us any pertinent information. By the way I just noticed in your queries that you are trying to do math with strings timeleft=timeleft-'1' WHERE timeleft<='0' I know MySQL does do type conversion, but still, you should use numbers in mathematical statements. 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.