I want to have a code that updates a row every hour, I know that cron job can do this, but I never can get cron jobs to work and thought this would be easier.
PHP Code:
if (date("h") == 11) //Hour 11
{
mysql_query("UPDATE `players` SET `shoppoints` WHERE $player->id");
}
From this nothing happens(when I click refresh), and I did click refresh at 11.
Im pretty sure for coding like this, you need to click refresh on that page and it wont add points when they arent on, but i know how to fix it to work good enough for me.
This runs off of your server's time, so if you're server is using CENTRAL US time, and you're computer is in EASTERN US time, then they wont be equal. So make sure you know the timezone your server is using.
No problem, if your host allows root access, to a WHM panel, you can usually alter the timezone from there, but to check just echo the date
PHP Code:
<?php echo date("h:i:s"); ?>
Be advised that the method your using, requires you to access the page manually, and if you refresh again it will allow you to update the DB again, for an hour because date("h") will remain the same for an hour, so anyone can access the file and refresh many times and reset the db.
Most I find will stick to GMT or UTF I think its under now.
Don't forget that you can change you're timezone with date_[default_]timezone_set. This link will provide you with the valid timezones: http://php.ca/manual/en/timezones.php
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php