Another problem with mysql version coding
| From: | NeXaS | Date: | Sun, 06 Apr 2003 03:37:14 +0000 |
| Subject: | Another problem with mysql version coding | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-142564@lists.php.net to get a copy of this message | ||
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