Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jan 2012
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Mysql update gold=gold-2 problem

    Hi, if gold is 2 than gold=2-2 and my update doesnt work .
    where is the answer ?? what should i do?

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,542
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Show us your code?

  • #3
    New Coder
    Join Date
    Jan 2012
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post
    if there is 2-1 it works, so :]

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Literal 2 - 1 would = 1. And literal 2 - 2 = 0.
    Post the SQL code you are using.

  • #5
    New Coder
    Join Date
    Jan 2012
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post
    Code:
     mysql_query("UPDATE gyvenvietes SET gold=gold-$gold WHERE gyvenvietes_pavadinimas='$stulpeliai[gyvenviete]'");
    :]]

  • #6
    New Coder
    Join Date
    Jan 2012
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post
    wow... now it works, maybe my xampp got something with that??

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    I can't see the web server changing a single thing. Assuming that PHP has always been parsed, if in one scenario it worked and another it did not, this indicates that likely the WHERE clause is incorrect, the query has failed, or a branch prevents it from ever attempting.
    Web servers won't just intermittently choose to execute something.


  •  

    Posting Permissions

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