Jump to content

sonny

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Everything posted by sonny

  1. Hi I have a cron Job that calls a php page that deletes old Msql data every 5hrs or so I have been thinking what would be the more efficient way to do this, at the time of display or time of insertion, or just keep doing it via cron job? I have a php page that displays data $query=" SELECT * FROM visits WHERE page='$page' && vcode='1' ORDER BY id DESC LIMIT 20"; $result=mysql_query($query) or die(mysql_error()); while($row =mysql_fetch_array($result)) and another php page that inserts it $queryup="UPDATE visits SET vcode='0' WHERE ip='$ip' && page='$page'"; $resultup=mysql_query($queryup) or die(mysql_error()); $query="INSERT INTO visits VALUES('NULL', '$ip', '$refer', '$page', '$flag', '$country', '$region', '$city', '$now', '1')"; $result=mysql_query($query) or die(mysql_error()); Looking for advice, on the most efficient and safest way to remove old data Thanks Sonny
  2. Thank you so much! it worked Would it be hard to covert that to 1 day if ever needed? or do I just add up the seconds. again thanks Sonny
  3. 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
  4. Hi Does anyone know the code for how to delete a old mysql entry older then X amount of seconds (2400 etc using a php page Sonny I have a table named "visits" and a unix time stamp field named "time"
  5. Hi Board The problem is any reminders which do not send within their hour and date, server down etc, will never get sent or deleted from the database. I have been trying to modify the code below, to get all unsent past reminders to go out the next time the reminder script runs. but am having no luck. Any help on this is appreciated Thanks ---------------------------- function send ($stamp) { global $db, $config; list ($day, $month, $year, $hour) = array(date('j', $stamp), date('n', $stamp), date('Y', $stamp), date('G', $stamp)); $query = "SELECT * FROM reminders WHERE date_day=$day AND date_month=$month AND date_year=$year AND date_hour=$hour"; $result = $db->query($query); if(DB::iserror($result)) { die("Error in send.<br>SQL: $query<br>" . $result->getMessage()); } $num_rows = $result->numRows(); for ($i = 0; $i < $num_rows; $i++) { $row = $result->fetchRow(DB_FETCHMODE_ASSOC); $newdate = array(); $to = $row['email_to']; $body = wordwrap($row['email_body']); $subj = $config['mail_subj_prepend'] . ' ' . $row['email_subject']; if ($to != '') { if (mail($to, $subj, $body, 'From: ' . $config['mail_from'])) { echo "\n(ID:{$row['id']}) E-mail Reminder sent to: <$to>"; }
×
×
  • 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.