Friday, October 23, 2009
What's wrong with my query? Deleting rows by date
Posted on 10:20 PM by programlover
Okay I am confused about why this does not work. Every reference I can find online including a post ofn this site says it should work.
php Code:
$today = date("Y-d-m");
echo "<h3> Today is: ". $today . "</h3>"; // gives the correct date in the proper format
mysql_query("DELETE FROM table WHERE date < '$today'")or die(mysql_error());
The date field is in date format in the DB and the seperators match (-).
It deletes all the entries in the database, two of which are older than today and three are in the future.