View Full Version : looking for a script..

10-19-2009, 07:27 PM
hey everyone, I am looking for a basic script that does the following

when a user visits the site they are given a score or number I can specify via the random function. This score is what they have until midnight then it resets to 0 and next time they visit they get a new score..( so in turn each day they would get a new score)

I've seen things like this out there but now that I need it I can't find it for the life of me and am still learning mysql date/time so writing it myself is not working out to well...

any info would be appreciated it..


10-19-2009, 09:05 PM
Do they log in, or are they anonymous users?

If they log in, the score is stored in their profile database,
if no log-in, you would have to use cookies. Not enough information.

10-19-2009, 09:20 PM
Hey mlseim, through dumb luck and a ton of reading and looking at tutorials and other scripts online -- I was able to figure out how to do the current date and store it in the Database..

the system I am using already has users who are registered and each user is assigned a certain userID which shows who is who.

The problem I am running into now is I have ot make a function I would assume that once a user comes to the site they are stored.

they are entered into my database like this currently (which is working)

uid, user, score, date

but I want to make it so that the user who visited today will not get an updated score, but instead get a message saying "Your Score is $score, come back tomorrow to get an updated score."

In my header I have this function

// Check if users exists
if( !check_user($user) ) {
not quite sure what to enter here

function located in userinc.php

// Check if user exists
function check_user( $u ) {

$res = query("SELECT * FROM `users` WHERE `userid` = $u");

list($total_rows) = mysql_fetch_array($res);

if( $total_rows > 0 ) return true;
else return false;


I'm a little stuck at this point, any suggestion would be greatly appreciated (sorry about first post being vague)

10-19-2009, 09:42 PM
Anything they do on your site, as the MySQL saves a date, will be your server time.
Who's clock will be the "official" clock? Your webhost's server?

Or, specify what the official website date and time really is.

That might be important if your user is 8 hours difference ... their tomorrow
may not be YOUR tomorrow. So determine that first.

You might be able to use some IP stuff to figure out their timezone?

Save a timestamp (UNIX time), like 1246306593, instead of Oct. 19, 2009 08:13:05

The math is then really simple. But MySQL does have many date/time conversions.
You'll have to Google that one.

People use the internet around the world, so you'll have to determine if you work
your site around them, or stick to your own time.

10-19-2009, 10:04 PM
ok that makes alot of sense and I was not thinking that broad either.. I will most likely make a set time timezone and go from there with it..

Thank you for that info though would of screwed me up down the road a little if i wasn't thinking that far ahead.