View Single Post
Old 07-05-09, 09:08 PM   #3
TSM
The Sick Man
Mega Poster
 
TSM's Avatar
 
Join Date: Nov 2004
Location: Peckham.SE.LDN
Posts: 4,768
Default Re: PHP / MySQL coders out there, script help

Quote:
Originally Posted by Baph View Post
TSM, far far far too over complicated....

Drop to a MySQL console, and play with the following...
Code:
$ndbconn = mysql_connect("localhost", "user", "password"); 
mysql_select_db("mysql"); 

$n_start_date = 1062521254; // Timestamp for 2003-09-02 11:47:34 taken from your DB 

// The query adds fourteen days to the given date 
$squery = "SELECT DATE_ADD(FROM_UNIXTIME($n_start_date), INTERVAL 14 DAY)"; 
$nresult = mysql_query($squery); 
$s_new_date = mysql_result($nresult, 0, 0); 

// Free the result 
mysql_free_result($nresult); 

// Disconnected 
mysql_close($ndbconn); 
echo "Your password will expire on $s_new_date";
Note the $squery variable.
Ahh i thought that route before but it does not work.
This is not for password usage, its for finding all records in a table where they are within the period to now.

Ie i have a table of log entries that has a list of image downloads that the client has done, client X has a limit of 50 images per month/week/quarter/year but the start of each period has to be keyed to their periodstart date, ie startperiod is 2009-01-31, if user had yearly limits on then the start date would be 2008-01-31, if it was monthly it would be 2008-12-31, if it was weekly then it would be 2009-01-24.
__________________
OTR: KTM 690 Duke R 2015 Full Akro
SIDELINE: Kwak ZX636 A1P 2002, Red, R&G's, Yoshi, Double Bubble Screen
GONE: Kwak ZX-7R P1, Full Akro, Undertray, Screen
GONE: SV650S K2 Very Bruised & Without Fairing, Motovation Frame Sliders, R&G Ally Sprocket Toe Protector, HEL 2 Line Setup, GSXR K1 600 RWU Forks, Barnett Clutch & Springs, Penske 8981 Shock, Gilles Ti Rearsets, Steel Barends, Scottoiler, AFAM Chain & Sprockets, Twin FIAMM Horns, Skidmarx Bellypan, Full Micron Zeta Steel System, Cut down undertay.

Forum Problems & Information / Site Suggestions
TSM is offline   Reply With Quote