SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    Norway
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reset User Table

    Im trying to reset all users in my table back to scratch, but not sure how I can do that so I need some help.

    I tried first something like this, but it didnt seem to work

    Code:
    mysql_query("UPDATE `$playerdb` (
      SET rank='0',
      SET clan='0',
      SET clan_tres='0',
    ........
    thanks for reading

    //R

  2. #2
    SitePoint Addict
    Join Date
    Feb 2004
    Location
    Staffordshire, UK & Florida, USA
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You were on the right lines, just your syntax was incorrect:
    Code:
    mysql_query("UPDATE `$playerdb` SET rank='0', clan='0', clan_tres='0',...
    Without a WHERE clause that will apply to all rows. You say that you are 'resetting' the user table - if you wanted to remove all the entries you could of course use DELETE FROM and if you have auto-increment IDs you could use TRUNCATE TABLE which will do the same as DELETE FROM but start the auto-increment sequence over again.

  3. #3
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    have you look at the mysql manual page for UPDATE? you have a pretty obvious syntax error.

    also, don't quote numbers. its not portable.

  4. #4
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    Norway
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok thanks I got it

    Here is my new sql query, but I get an error but cant see whats wrong and all the table names are correct, but I havent double checked

    Code:
    UPDATE long2_players (
      SET rank=0,
      clan=0,
      clan_tres=0,
      forces=0,
      allytime=0,
      attacks=0,
      offsucc=0,
      offtotal=0,
      defsucc=0,
      deftotal=0,
      kills=0,
      turns=0,
      turns_last=0,
      hour_last=0,
      turnsstored=0,
      turnsused=0,
      networth=0,
      cash=100000,
      food=10000,
      peasants=500,
      health=100,
      wizards=0,
      runes=500,
      shield=0,
      gate=0,
      land=250,
      shops=5,
      homes=20,
      industry=0,
      barracks=5,
      labs=0,
      farms=15,
      towers=0,
      freeland=205,
      tax=10,
      savings=0,
      turnbank_last=0,
      turnbank=0,
      loan=0,
      pvmarket_last=0,
      pmkt_food=100000,
      bmper_last=0,
      aidcred=5,
      aidcred_got=0,
      msgcred=10,
      msgcred_got=0,
      msgtime=0,
      newstime=0,
      loggedin=0,
      hero_war=0,
      hero_peace=0,
      hero_special=0,
      heroes_used=0,
      warset=0,
      warset_time=0,
      warset_known=0,
      peaceset=0,
      peaceset_time=0, 
      l_attack=0,
      num_bounties=0,
      hide=0,
      condense=1,
      atkforstruct=1,
      folders=0,
      menu_lite=0,
      validated=1,
      vote=0,
      newssort=0,
      std_bld=1,
      motd=0,
      lastdroptime=0
    Error message I get

    Quote Originally Posted by phpmyadmin
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(
    SET rank=0,
    clan=0,
    clan_tres=0,
    forces=0,
    allytime=0,
    attac' at line 1

  5. #5
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    you still have the same error that djones pointed out.
    Last edited by longneck; Mar 18, 2008 at 09:20.

  6. #6
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    Norway
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I removed the ( and it worked


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
  •