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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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