Results 1 to 7 of 7

Thread: game reset

  1. #1
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    133
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default game reset

    i am trying to make the game reset, i attempted but i KNOW its not right coding

    can you help me change it so that it does what i want it to do?

    PHP Code:
    <?php
    include('connect.php');
    $now time ($a$b$c$d$e$f) ;


    $thetime mysql_fetch_array(mysql_query("select * from time"));

    mysql_query("update time set minute=$b, second=$c, day=$d, month=$e, year=$f");

    if (
    a$ > $thetime[hour] ) {

    mysql_query("update time set hour=$a");

        
    mysql_query("update km_users set pj=maxpj");
        
    mysql_query("update km_users set hp=maxhp where hp<maxhp");
        
    mysql_query("update km_users set battles=0");
        }

    ?>
    http://www.insanecombat.com << bored? check out ma game

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    As in the other thread, you should consult a PHP tutorial. There are a lot of things just wrong with the script that you can learn.
    http://php-mysql-tutorial would apply here as well.

    1. It's generally function(...), not function (...). Not a big issue, but odd and less readable.
    2. time() has no arguments. It returns the number of seconds since 1970, which can be used to create a readable date with date(), etc. It's something like 110000000 right now.
    3. $thetime will not do anything... I'm not sure what you want with it.
    Using mysql_query with SELECT will return a SET of results. See the tutorial above for how to deal with this. mysql_fetch_array will return only the first of the returned rows (and there are almost certainly many rows as there is no limit or where requirement, etc.). Using it as is will just get the first one.
    4. Your update query that is wrong, as those variables aren't defined. And the entire query is just the wrong syntax, and there is no where requirement, so it would pick one at random, I guess. Look that up.
    5. Why are the last few lines indented and the one above not? You should be consistent so it's easy to read.
    6. the last queries seem fairly reasonble, but still not very controlled.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    133
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default

    so could i set each number in the time function as a variable?
    http://www.insanecombat.com << bored? check out ma game

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I dunno what you're trying to do.
    date() will give you a usable representation of time().
    http://www.php.net/manual/en/function.date.php
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    133
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default

    PHP Code:
    <?php
    include('connect.php');

    $now date(H);

    $thetime mysql_fetch_array(mysql_query("select * from time"));

    if (
    $now $thetime[hour] ) {

            
    mysql_query("update time set hour=$now");
        
    mysql_query("update km_users set pj=maxpj");
        
    mysql_query("update km_users set hp=maxhp where hp<maxhp");
        
    mysql_query("update km_users set battles=0");
        }

    ?>
    could that work?
    http://www.insanecombat.com << bored? check out ma game

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    1. You are still not uses quotes for the keys to arrays.
    ['hour'], not [hour].
    2. date(H) will give an error. Quotes. date('H').
    3. Tabs are still a bit weird.
    4. You aren't limiting those updates. Are you sure you want to do that? Just change all records? (except the third.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    133
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default

    lol for number 4 the answer is yes
    http://www.insanecombat.com << bored? check out ma game

Bookmarks

Posting Permissions

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