Need help with 1 line

Discussion in 'PHP' started by x0x, Jul 6, 2008.

  1. #1
    SET credits=credits+$turns
    Code (markup):
    What I wanna do is make it add + 25% to $turns

    I made

    SET credits=credits+$turns*1,25
    Code (markup):
    but it didn't work

    so if turns is 100 and credits is 20 it would do 20 + 125 because 25% of 100 is 25 and 25+100 is 125

    why didn't it work? should I use , or .?
     
    x0x, Jul 6, 2008 IP
  2. nicangeli

    nicangeli Peon

    Messages:
    828
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well I don't have a clue what your code is doing, I must be a n00b. To add 25% to $turns you do,

    
    $turns = $turns * 1.25;
    
    PHP:
     
    nicangeli, Jul 6, 2008 IP
  3. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Nicangeli: It's SQL code (you probably knew), but yes - this would be a lot simpler. Just multiply it via PHP and then simply add the variable in MySQL

    Whether you should use , or . depends on your locale settings, I would recommend trying . first - always print mysql_error() if you think it didn't work so you know why it failed.

    Dan
     
    Danltn, Jul 7, 2008 IP
    nicangeli likes this.
  4. nicangeli

    nicangeli Peon

    Messages:
    828
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #4
    :D

    I must have been having a funny moment then...(I just didn't click!).
     
    nicangeli, Jul 7, 2008 IP