Jump to content

Recommended Posts

Hey duuudes, i've got a mysql which holds an events section of my site, at the moment i log in each day and delete all entries with a date older than the current date, but yeah, i need this to be automatic really. I've set up a CRON on the server, which runs cron.php at 3 in the morning each day. In this php page i've got the following code....

 

<?
$date = date("Y-m-d");

mysql_connect ("localhost","###","###");
@mysql_select_db("###") or die ("unable to connect");

$query = "DELETE FROM events_backup WHERE 'date' < $date ;";

$result = mysql_query($query); 

mysql_close();

echo "$date ";
?>

 

I thought this would be fairly simple but alas, i've tried it on my back up table (events_backup) and it deleted all the data!

 

poo

haha my fault, simple error, should have checked!

 

<?
$date = date("Y-m-d");

mysql_connect ("localhost","maddogma_listing","mightyb00sh");
@mysql_select_db("maddogma_listings") or die ("unable to connect");

$query = "DELETE FROM events WHERE date < '$date' ;";



$result = mysql_query($query); 

mysql_close();

?>

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.