Jump to content

[SOLVED] More control over time() needed or something else to slow this down?


djfox

Recommended Posts

In a previous post, it was told to me to use time() for a function I`m working on. First, I`ll share the code:

 

<?php
$time= time();

if ($time=time()+3600) {  

$petfood= $rows[5] -2;
   mysql_query("UPDATE ownedpets SET food=$petfood WHERE id='$id'");
}
?>

 

What this is supposed to do is subtract 2 from $rows[5] every hour. But instead what is happening is that 2 is subtracted from $rows[5] every time the page loads. Changing the time (right now it`s 3600) doesn`t affect it at all. Am I doing something wrong?

Link to comment
Share on other sites

Why do you need to update your database every hour? Are you feeding as pet?

 

Yes, it`s for the virtual pet system I`m developing for my site. The hunger meter of all the pets need to go down by a time interval, to encourage the owners to feed the pet.

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.