Jump to content

Banner Expire help


balkan7

Recommended Posts

hi

i have created code for banner expire but not working, there is code of expire and datebase fields:

db fields:

CREATE TABLE `lab_btr_banners` (
  `banner_id` int(10) NOT NULL auto_increment,
  `banner_type` tinyint(1) NOT NULL default '0',
  `banner_state` tinyint(1) NOT NULL default '0',
  `client_id` int(11) NOT NULL default '0',
  `banner_plans` int(11) NOT NULL default '0',
  `banner_name` varchar(255) NOT NULL default '',
  `banner_clicks` text NOT NULL,
  `banner_date` datetime default NULL,
  `banner_expire` int(11) NOT NULL default '0',
  `banner_end` datetime default NULL,
  `banner_url` varchar(255) NOT NULL default '',
  `banner_img` varchar(255) NOT NULL default '',
  `banner_html` text NOT NULL,
  PRIMARY KEY  (`banner_id`)
) TYPE=MyISAM AUTO_INCREMENT=6 ;

 

php code for expire:

<?php $upload_date = date("Y-m-d", $data['banner_date']);
    $now = time();
    $month = $data['banner_expire'];
    $difference = ($now - $upload_date);
    if($difference > $month){
 	   $finish = "";
	   } else {
	   $finish = dbquery("UPDATE ".$db_prefix."btr_banners SET banner_state = '0', banner_end = NOW( ) WHERE banner_id = ".$banner_id."");
	  }?>

Link to comment
https://forums.phpfreaks.com/topic/83742-banner-expire-help/
Share on other sites

Your code seems rather confused to me. On the first line, you use $data['banner_date']; as if it is a timestamp. However, you later assign it to a variable called $month. You also try to take away a string in the format Y-m-d from a timestamp.

 

Perhaps if you explained a bit more about how this is supposed to work, where the information comes from and in what format it is in, we could help you.

Link to comment
https://forums.phpfreaks.com/topic/83742-banner-expire-help/#findComment-426146
Share on other sites

soryy i change 3 fields in datebase:

banner_date varchar(100) NOT NULL default '',

banner_expire varchar(100) NOT NULL default '',

banner_end varchar(255) NOT NULL default '',

 

now i get date in this format: 1199046285

 

now code what i used for expire, in field banner_expire have secodns: 2592000 ->(30 days) below script check time for expire but not working from me where i wrong ?:

<?php
$upload_date = date('d-m-Y', $data['banner_date']);
    $now = time();
    $month = $data['banner_expire'];
    $difference = ($now - $upload_date);
    if($difference > $month){
 	   $finish = "";
	   } else {
	   $finish = dbquery("UPDATE ".$db_prefix."btr_banners SET banner_state = '0', banner_end = NOW( ) WHERE banner_id = '".$banner_id."'");
	  }?>

Link to comment
https://forums.phpfreaks.com/topic/83742-banner-expire-help/#findComment-426155
Share on other sites

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.