Jump to content

Delete after X hours


Joshua F

Recommended Posts

I am trying to make a function that is customizable to delete a query from a database.

 

Here's the function.

function checkHashs($hours) {
        if($getHashs = mysql_query('SELECT * FROM `hash_codes`')) {
          $dateQ = mysql_query('SELECT MAX(addedon) AS lastVoteDate FROM `hash_codes`') or die(mysql_error());
          $getDate = mysql_fetch_assoc($dateQ);
          $diffrence = time() - strtotime($getDate['lastVoteDate']);
		  echo $diffrence / 60 / 60;
          if (($diffrence / 60 / 60) >= $hours) {
			mysql_query('DELETE FROM `hash_codes` WHERE `addedon` = '. ($diffrence / 60 / 60) >= $hours .'') or die(mysql_error());
          }
}
}

 

And I am trying to call it by

checkHashs(24);

 

What I am trying to do is make it so when that function is ran it will delete all oh the guerys that have the `addedon` row over X hours(24 hours in this case).

 

Any ideas?

Link to comment
Share on other sites

Your delete query is wrong...check and recheck...the construct is wrong..

 

 

I am trying to make a function that is customizable to delete a query from a database.

 

Here's the function.

function checkHashs($hours) {
        if($getHashs = mysql_query('SELECT * FROM `hash_codes`')) {
          $dateQ = mysql_query('SELECT MAX(addedon) AS lastVoteDate FROM `hash_codes`') or die(mysql_error());
          $getDate = mysql_fetch_assoc($dateQ);
          $diffrence = time() - strtotime($getDate['lastVoteDate']);
		  echo $diffrence / 60 / 60;
          if (($diffrence / 60 / 60) >= $hours) {
			mysql_query('DELETE FROM `hash_codes` WHERE `addedon` = '. ($diffrence / 60 / 60) >= $hours .'') or die(mysql_error());
          }
}
}

 

And I am trying to call it by

checkHashs(24);

 

What I am trying to do is make it so when that function is ran it will delete all oh the guerys that have the `addedon` row over X hours(24 hours in this case).

 

Any ideas?

Link to comment
Share on other sites

Your delete query is wrong...check and recheck...the construct is wrong..

 

 

I am trying to make a function that is customizable to delete a query from a database.

 

Here's the function.

function checkHashs($hours) {
        if($getHashs = mysql_query('SELECT * FROM `hash_codes`')) {
          $dateQ = mysql_query('SELECT MAX(addedon) AS lastVoteDate FROM `hash_codes`') or die(mysql_error());
          $getDate = mysql_fetch_assoc($dateQ);
          $diffrence = time() - strtotime($getDate['lastVoteDate']);
		  echo $diffrence / 60 / 60;
          if (($diffrence / 60 / 60) >= $hours) {
			mysql_query('DELETE FROM `hash_codes` WHERE `addedon` = '. ($diffrence / 60 / 60) >= $hours .'') or die(mysql_error());
          }
}
}

 

And I am trying to call it by

checkHashs(24);

 

What I am trying to do is make it so when that function is ran it will delete all oh the guerys that have the `addedon` row over X hours(24 hours in this case).

 

Any ideas?

?????????

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.