Jump to content

Very simple script randomly stopped working and won't work again...


acidpunk

Recommended Posts

:confused: 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' :wtf:

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.....

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.