Jump to content

[SOLVED] Removing old MySQL data with php page


sonny

Recommended Posts

That does not delete anything, even if I set it for 1 second

 

Here is what the database looks like

 

CREATE TABLE `visits` (
  `id` int(11) NOT NULL auto_increment,
  `ip` varchar(20) NOT NULL default '',
  `country` varchar(50) NOT NULL default '',
  `region` varchar(50) NOT NULL default '',
  `city` varchar(50) NOT NULL default '',
  `time` int(11) NOT NULL default '0',
  `vcode` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`)
);

 

This is what the time field looks like

(unix time)-->1248106995

 

this what my php looks like I tested with

<?php

require "./connect.php";
$before = time() - 5;
$sql = "DELETE FROM `visits` WHERE `time`< '$before'";

?>

 

I would like to delete entry's older then x amount of seconds to test first

 

Thanks for helping

Sonny

oh...well...you need to add a mysql_query() to it...i just assumed you knew to do that:

<?php

require "./connect.php";
$before = time() - 5;
$sql = "DELETE FROM `visits` WHERE `time` < '$before'";
mysql_query($sql) or die(mysql_error());

?>

Archived

This topic is now archived and is closed to further replies.

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