PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Just maintain the lastDownload field as Integer and you won't need that. There really is no need to convert from int to date as you are comparing integers not dates.
function allowDownload ($userid)
{
$sql = "SELECT `lastDownload` FROM `users` WHERE `userid` = '{$userid}'";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
if ((intval($row['lastDownload']) + 86400) > time()) {
//user has downloaded a file within the last 24hrs..
return false;
} else {
return true;
}
}