Results 1 to 3 of 3

Thread: PHP Help!

  1. #1
    Join Date
    Apr 2006
    Location
    Salford
    Posts
    2,108
    Tokens
    0

    Latest Awards:

    Default PHP Help!

    Ok, well basicly im coding a feature for my game, ive done most of it, i just need some help.

    I want it so everynight at 12pm, it updates a random username from 'users' in the database.

    Im not sure how to go about this, any help?

  2. #2
    Join Date
    Feb 2006
    Location
    Scotland
    Posts
    2,087
    Tokens
    138

    Latest Awards:

    Default

    I did try to write the code but at 2 in the morning, I was simply too tired too!

    Someone else probably will and do it better but oh well!

    Set an integer to randomly generate using rand();

    Simply you use the date(h:i); function to grab the current server time (e.g - 12:21) and set that as a variable.

    Then set the time you want the thing to occur as another variable - ($otime = '00:00'

    Then simply query the database ($query = mysql_query('SELECT id FROM users WHERE id = `$rand`')

    Then do mysql_num_rows to see if that id exists within the table.

    then an if/else statement:

    if ($num>0 && $time == $otime) {

    // update

    } else {

    // redo using the same stuff as above

    }

    I think that method would work but I seriously have no idea at this time!

    If I have time tomorrow and nobody else has, ill give it a go
    Last edited by Johno; 23-08-2008 at 01:29 AM.

  3. #3
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    Running a recursive service on your server, will be annoying, and unreliable.

    Alternatively, and much less resourcefully, you could create a cron job, which is a script that in *nix can be made to run every x, ask your webhost, of if you tell me who your web host is, i can try and walk you through it.
    Last edited by Hypertext; 23-08-2008 at 01:46 AM.
    How could this hapen to meeeeeeeeeeeeeee?lol.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •