cliftonbazaar Posted January 26, 2011 Share Posted January 26, 2011 Have started to program my own cricket management game and wish to have the database update every 60 seconds; this is to facilitate players who are not watching the actual game. Games are starting (and finishing) at all times so it is not possible to allow the user to be the only one to activate the game code; it is also not possible to only play the games when the human players are online because other games depend on the results. The only answer I can think of at the moment is to have a copy of firefox running on the server which runs the PHP code to update all current games and have this page automatically refresh every 60 seconds. Is this even viable? Any other suggestions? James Quote Link to comment https://forums.phpfreaks.com/topic/225791-updating-database-every-60-seconds/ Share on other sites More sharing options...
Maq Posted January 26, 2011 Share Posted January 26, 2011 You're going to have to use a cron job to run your updating script every minute. Quote Link to comment https://forums.phpfreaks.com/topic/225791-updating-database-every-60-seconds/#findComment-1165684 Share on other sites More sharing options...
QuickOldCar Posted January 26, 2011 Share Posted January 26, 2011 You can create a cron job for the php code to just update the database. If you really need firefox to open for some reason it can be opened and closed running in background on the server. Not sure linux, windows, but opening and closing firefox can be done by using bat files or some sort of exec, psexec to open and close in a timely manner. All the permissions and that good stuff will have to be worked out. If need to actually have a firefox window open and playing but do a refresh , can add a header or meta redirect to refresh your pages. meta refresh every 30 seconds same content page <?php echo('<meta http-equiv="refresh" content="30">'); ?> meta refresh in 30 seconds to a new page <meta http-equiv="refresh" content="30;url=http://somesite.com/somepage.php"> using header <?php header( "refresh:30;url=somepage.php" ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/225791-updating-database-every-60-seconds/#findComment-1165703 Share on other sites More sharing options...
XistenceNL Posted January 26, 2011 Share Posted January 26, 2011 http://www.phpfreaks.com/forums/php-coding-help/php-refresh-322187/?all Look at the last reply with attachment. That's the way to go for you my friend. I use that for a internet chatapp. You can use it for like the scoreboard or something Quote Link to comment https://forums.phpfreaks.com/topic/225791-updating-database-every-60-seconds/#findComment-1165712 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.