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 3 of 3
  1. #1
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,383
    Thanks
    264
    Thanked 32 Times in 31 Posts

    negative result question

    Hi,

    so im taking a value of current val and subtracting a cost value like this

    PHP Code:

    $updatecred 
    $mem_curcred $featurecost
    I do check the avail credits before hand but i was thinking what if the user waits awhile and just lets the page sit there then finishes, it could by pass my number of cred avail check.

    So what i want to do is just verify before i post in the db that this result of $updatecred is NOT a neg number.

    I know this sounds soo noobish but i really dont know. Do i just check for < 0 or if i use intval will that make sure it is not < 0

    Which is best, if it is < 0 i just want it to be 0.

    thanks
    Last edited by durangod; 12-01-2012 at 04:17 AM.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Yes, Just make it zero ...

    if($updatecred < 0){
    $updatecred=0;
    }

  • Users who have thanked mlseim for this post:

    durangod (12-01-2012)

  • #3
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,383
    Thanks
    264
    Thanked 32 Times in 31 Posts
    thanks thats how i had it just wanted to be sure lol.. thanks so much


  •  

    Posting Permissions

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