SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Update whole dtabase

    i got this code im trying to make it update the online field for all my members to n:

    PHP Code:
    $query 'UPDATE b_users SET online"'n'" WHERE username="*'"'; 

  2. #2
    SitePoint Addict
    Join Date
    Apr 2005
    Posts
    287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm pretty sure you can take out the WHERE username="*'" if you want to effect all users.
    How does that make your feel?

  3. #3
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not working
    PHP Code:
    <?
    include "db_connect.php";
    $query 'UPDATE b_users SET online"n"'
    ?>

  4. #4
    SitePoint Addict silentcollision's Avatar
    Join Date
    Jun 2006
    Location
    New Zealand
    Posts
    388
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $query "UPDATE b_users SET online='n'"
    ?

    Off Topic:

    I think we might have TicTac v2 here.

  5. #5
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    didnt sstill not working

  6. #6
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone?

  7. #7
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    when you say it doesnt work, what do you mean? Do you get any errors or does it just not update the database?

    If you are setting your entire users database to online then silentcollisions code would haev worked. what does the code look like now?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  8. #8
    SitePoint Member megamoose's Avatar
    Join Date
    Oct 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mike4x4s View Post
    not working
    PHP Code:
    <?
    include "db_connect.php";
    $query 'UPDATE b_users SET online"n"'
    ?>
    All you're doing is setting a variables value. You're not actually doing anything with $query as far as I can see, unless you have some other code you're not telling us.

    Also online"n" should probably be `online` = "n"

    Mark
    .

  9. #9
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Code:
    UPDATE b_users SET online = 'n'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  10. #10
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not working, it jsut dosnt update the database.

  11. #11
    SitePoint Member megamoose's Avatar
    Join Date
    Oct 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mike4x4s View Post
    not working, it jsut dosnt update the database.
    Mike did you read my last reply? You don't appear to be doing anything to the database, your just setting the $query variable. You need to execute the $query somehow.

    Mark
    .

  12. #12
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    include('db_connect.php');
    $query "UPDATE b_users SET online = 'n'";
    mysql_query($query) or die(mysql_error()); 

  13. #13
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that code worked thanks.

  14. #14
    SitePoint Addict silentcollision's Avatar
    Join Date
    Jun 2006
    Location
    New Zealand
    Posts
    388
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You weren't executing the query?

    You might want to look up basic PHP structure and tutorials before asking questions.

  15. #15
    SitePoint Addict tbakerisageek's Avatar
    Join Date
    Sep 2006
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by silentcollision View Post
    Off Topic:

    I think we might have TicTac v2 here.
    No, he hasn't asked about barcodes yet.

  16. #16
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Eyes are watching.....
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


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
  •