RE: [PHP] Another problem with mysql version coding

From: Date: Sun, 06 Apr 2003 02:42:21 +0000
Subject: RE: [PHP] Another problem with mysql version coding
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-142565@lists.php.net to get a copy of this message
You should be asking these questions on a MySQL list... DELETE FROM table WHERE laikas < NOW() - INTERVAL 60 DAY AND admin != 1 Works on MySQL 3 and 4. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ > -----Original Message----- > From: NeXaS [mailto:nexas@mntkz.net] > Sent: Saturday, April 05, 2003 10:37 PM > To: php-general@lists.php.net > Subject: [PHP] Another problem with mysql version coding > > Hey all, the next code i wrote is for deleting users who don`t login > for 60 days. This script should work under 4.x.x series of MySQL DB, > but i have 3.x.x version. What should i change in this code that it > should work on 3.x.x version of MySQL. ( time is given as a timestamp > ( saved as time() in mysql ) ). > > The Code: > > $GLOBALS['data'] = date ("Y-m-d",$timelt); > $GLOBALS['laik'] = date("H:i:s",$timelt); > $queriz = "SELECT vartotojas, laikas FROM useriai WHERE > (CAST(UNIX_TIMESTAMP(NOW()) AS SIGNED) - CAST(UNIX_TIMESTAMP(laikas) AS > SIGNED))>5184000 AND admin != '1'"; > $rezult = mysql_query($queriz); > if (mysql_num_rows($rezult) != 0) { > while ($row2 = mysql_fetch_array($rezult)) { > $ka = $row2['vartotojas']; > $query = "INSERT INTO logai SET kas='SISTEMA', ka='$ka', > data='$GLOBALS[data]', laikas='$GLOBALS[laik]'"; > echo mysql_error(); > mysql_query($query); > $delete = "DELETE FROM useriai WHERE > (CAST(UNIX_TIMESTAMP(NOW()) AS SIGNED) - CAST(UNIX_TIMESTAMP(laikas) AS > SIGNED))>5184000 AND admin != '1'"; > $del = mysql_query($delete); > } > } > > > P.S. It Also add info to mysql db as logo who delete the user ;-) > > Thanks if someone could help! NeXaS > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#142565) next »