Jump to content

Simple yet boggled


apw

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.