can you notice

Discussion in 'PHP' started by demons-halo, Sep 25, 2009.

  1. #1
    Can anyone see a problem with this script??

    <?php
    include "globals.php";
    {
    $price=($ir['hp']);
    $chest=($ir['maxhp']);
    $main=($chest - $price);
    }
    if($fm < $main)
    {
    echo "You can't afford to heal yourself";
    }
    else
    {
    $db->query("UPDATE users SET money=money-$main WHERE userid=$userid");
    $query4="UPDATE users SET hp=maxhp WHERE hp>maxhp";
    $db->query($query4);
    print "You healed yourself";
    }
    ?>
    PHP:
    cos when i run this script, when $fm is greater than $main it still shows the you cant afford to be healed.

    anyone know why??
     
    demons-halo, Sep 25, 2009 IP
  2. TheOnly92

    TheOnly92 Peon

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    {
    $price=($ir['hp']);
    $chest=($ir['maxhp']);
    $main=($chest - $price);
    }
    PHP:
    I wonder what are the brackets for here?
     
    TheOnly92, Sep 25, 2009 IP
  3. demons-halo

    demons-halo Active Member

    Messages:
    243
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #3
    i dont know, this is how i got the script, shoul i take them all out?
     
    demons-halo, Sep 25, 2009 IP
  4. orionoreo

    orionoreo Peon

    Messages:
    145
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    if you can run it the brackets may not affect anything

    your if conditions should not fail you

    why don't you put echo $fm and echo $main before the if condition to see if the variables has changed in the process
     
    orionoreo, Sep 25, 2009 IP
  5. demons-halo

    demons-halo Active Member

    Messages:
    243
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #5
    i think ive found the problem, the $fm variable has a $ sign infront of the numbers, so could this be affecting it, when the $fm is displayed in an echo command it shows '$10000' cos its a currency variable, could that $ sign be affecting it
     
    demons-halo, Sep 25, 2009 IP
  6. demons-halo

    demons-halo Active Member

    Messages:
    243
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #6
    how can i read from the database with this code

    SELECT * FROM `users` WHERE 1`money`

    and make the money field a variable??
     
    demons-halo, Sep 25, 2009 IP
  7. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #7
    You could learn PHP and SQL by the time you break down all your codes and ask about all of them. I answered your similar post in another thread. :D
     
    ezprint2008, Sep 25, 2009 IP
  8. newgenservices

    newgenservices Well-Known Member

    Messages:
    862
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    105
    Digital Goods:
    1
    #8
    You can probably check the other two threads of yours where I gave you some code which you can use to get both of these issues solved :)
     
    newgenservices, Sep 25, 2009 IP