Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-06-2008, 12:11 AM php time() help
Average Talker

Posts: 20
Name: Shane
Trades: 0
So I am trying to set up a little script that only allows users to interact with it every 30 minutes - hour or so. I tried something like this:

PHP Code:
<?php
$now 
time();
$result mysql_query("SELECT * FROM example WHERE user='$user'"
or die(
mysql_error());
$row mysql_fetch_array($result);
$last $row['time'];
$timecheck $now $last;
if (
$timecheck 3600){
// do something
// update the time in the table for next time
} else {
// tell user she can't do that yet
}
?>
I get random things though. Negative numbers. It fluctuates and I just can't get it to work reliably. Any suggestions on what to do?
Demexii is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-06-2008, 12:56 AM Re: php time() help
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
What is the value of $row['time'] in your DB? How do you set it?
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 03-06-2008, 01:18 AM Re: php time() help
Average Talker

Posts: 20
Name: Shane
Trades: 0
Quote:
Originally Posted by mtishetsky View Post
What is the value of $row['time'] in your DB? How do you set it?
time(); at the moment they accessed it previously. I store the time they access it into the db and then when they access it again I check the new time against the time they last accessed it.
Demexii is offline
Reply With Quote
View Public Profile
 
Old 03-06-2008, 01:27 AM Re: php time() help
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
What is the type of 'time' field in your table? Which query do you use to set it?
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 03-06-2008, 02:26 AM Re: php time() help
Average Talker

Posts: 20
Name: Shane
Trades: 0
Quote:
Originally Posted by mtishetsky View Post
What is the type of 'time' field in your table? Which query do you use to set it?
Depends on the situation but just grab the time (time() and put it into the mySQL db under time. Uses bigint.
Demexii is offline
Reply With Quote
View Public Profile
 
Old 03-06-2008, 02:29 AM Re: php time() help
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
All ints are signed in mysql by default. You should change it to unsigned.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to php time() help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30291 seconds with 12 queries