Greystoke Posted May 24, 2010 Share Posted May 24, 2010 Hi, I want this to run only once every 5 days or greater. The problem is, it is running every time the page is opened. It updates the last_modified field but not the configuration_value field. Can anyone help with this please. <?php $prev = tep_db_query("select * from " . TABLE_CONFIGURATION . " where configuration_key = 'CRON_BD_RUN'"); if (tep_db_num_rows($prev) > 0) { $prev_val = tep_db_fetch_array($prev); if($prev_val['configuration_value'] <= (date("Ymd") - 5)) { echo 'Test Code'; tep_db_query("UPDATE " . TABLE_CONFIGURATION . " SET configuration_value = '" . date("Ymd") . "', last_modified = now() WHERE configuration_key = 'CRON_BD_RUN'"); } } else { tep_db_query("INSERT INTO ".TABLE_CONFIGURATION." (CONFIGURATION_KEY, configuration_value, CONFIGURATION_GROUP_ID) VALUES('CRON_BD_RUN', '".date("Ymd")."', 6)"); } ?> CREATE TABLE IF NOT EXISTS `osc_configuration` ( `configuration_id` int(11) NOT NULL auto_increment, `configuration_title` varchar(255) collate utf8_unicode_ci NOT NULL, `configuration_key` varchar(255) collate utf8_unicode_ci NOT NULL, `configuration_value` varchar(255) collate utf8_unicode_ci NOT NULL, `configuration_description` varchar(255) collate utf8_unicode_ci NOT NULL, `configuration_group_id` int(11) NOT NULL, `sort_order` int(5) default NULL, `last_modified` datetime default NULL, `date_added` datetime NOT NULL, `use_function` varchar(255) collate utf8_unicode_ci default NULL, `set_function` varchar(255) collate utf8_unicode_ci default NULL, PRIMARY KEY (`configuration_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=201 ; Quote Link to comment https://forums.phpfreaks.com/topic/202760-run-code-if-greater-than-or-equal-to-5-days/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.