apw Posted June 30, 2008 Share Posted June 30, 2008 My question this time is about updating my database every two hours on the odd hour. The reason for this is for my turned-based game each odd hour the sql database needs to update the pfile portion pturns amd give each player a turn. Im thinking javascript what do you think to make this simple? Quote Link to comment Share on other sites More sharing options...
mikefrederick Posted June 30, 2008 Share Posted June 30, 2008 if(hour%2==1) { update } Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 30, 2008 Share Posted June 30, 2008 Use cron for this. Quote Link to comment Share on other sites More sharing options...
apw Posted June 30, 2008 Author Share Posted June 30, 2008 The host im using doesnt allow cron-jobs Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 30, 2008 Share Posted June 30, 2008 So use your own. On a Linux box, just set up a cron to use wget on the remote PHP page, causing it to execute. Quote Link to comment Share on other sites More sharing options...
Jabop Posted June 30, 2008 Share Posted June 30, 2008 Or if the page is visited enough, make a column or table that stores the last update. When the page is viewed, check now vs the last update and if it is what you want, run the update script. It's not the best way to do it (cron is), but it gets the job done. Quote Link to comment Share on other sites More sharing options...
apw Posted June 30, 2008 Author Share Posted June 30, 2008 I would but dont own linux box unless theres a free host that offers cron Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 30, 2008 Share Posted June 30, 2008 What do you use right now? Windows? Just switch to Linux. Quote Link to comment Share on other sites More sharing options...
apw Posted July 1, 2008 Author Share Posted July 1, 2008 I use a paid hosting account that doesn't allow the use of cron. I've seen a few php scripts like black nova traders have a javascript that uses a counter to update their database like this: ?><br> <center> <? // Update counter $res = $db->Execute("SELECT last_run FROM $dbtables[scheduler] LIMIT 1"); $result = $res->fields; $mySEC = ($sched_ticks * 60) - (TIME()-$result[last_run]); ?> <script language="javascript" type="text/javascript"> var myi = <?=$mySEC?>; setTimeout("rmyx();",1000); function rmyx() { myi = myi - 1; if (myi <= 0) { myi = <? echo ($sched_ticks * 60); echo "\n";?> } document.getElementById("myx").innerHTML = myi; setTimeout("rmyx();",1000); } </script> <? echo " <b><span id=myx>$mySEC</span></b> $l_footer_until_update <br>\n"; // End update counter now if I could reword this to update my database pfile for the players turns that would be great .. Thanks Quote Link to comment Share on other sites More sharing options...
interpim Posted July 1, 2008 Share Posted July 1, 2008 there are websites out there that will allow you to do a remote cron... some are free, some have a small fee... I would google search it and see if that will fit your bill. Quote Link to comment Share on other sites More sharing options...
apw Posted July 1, 2008 Author Share Posted July 1, 2008 Since the web-game is still under heavy dev i was planning just to move the entire site to one that offers cron .. Shouldnt need much room .. So far im barely using 10k worth space on sql Quote Link to comment 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.