Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-01-2012, 03:58 AM   PM User | #1
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,177
Thanks: 214
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
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..
durangod is offline   Reply With Quote
Old 12-01-2012, 04:13 AM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Yes, Just make it zero ...

if($updatecred < 0){
$updatecred=0;
}
mlseim is offline   Reply With Quote
Users who have thanked mlseim for this post:
durangod (12-01-2012)
Old 12-01-2012, 04:17 AM   PM User | #3
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,177
Thanks: 214
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
thanks thats how i had it just wanted to be sure lol.. thanks so much
durangod is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:18 PM.


Advertisement
Log in to turn off these ads.