Re: [PHP] shortest possible check: field is set, integer or 0

2005-12-02 Thread Jochem Maas
Steve Edberg wrote: At 5:30 PM +0100 12/1/05, Jochem Maas wrote: Steve Edberg wrote: Only problem with intval() is that it returns 0 (a valid value) on I knew that. :-) I figured so, but I thought I'd make it explicit for the mailing list... failure, so we need to check for 0 first.

Re: [PHP] shortest possible check: field is set, integer or 0

2005-12-02 Thread Marco Kaiser
whats with if (isset($_POST['field']) (INT)$_POST['field']=0) { ? This should cover the requirements. $_POST['field'] should be eq 0 or higher as int. (INT) converts 1.44 to 1 (cuts .44) -- Marco 2005/12/2, Jochem Maas [EMAIL PROTECTED]: Steve Edberg wrote: At 5:30 PM +0100 12/1/05,

Re: [PHP] shortest possible check: field is set, integer or 0

2005-12-01 Thread Jochem Maas
Ray Hauge wrote: Richard Lynch wrote: On Wed, November 30, 2005 5:10 pm, Chris Lott wrote: What is the shortest possible check to ensure that a field coming from a form as a text type input is either a positive integer or 0, but that also accepts/converts 1.0 or 5.00 as input?

Re: [PHP] shortest possible check: field is set, integer or 0

2005-12-01 Thread Steve Edberg
Only problem with intval() is that it returns 0 (a valid value) on failure, so we need to check for 0 first. Adding more secure checks would make this more than just a one-liner, eg; $_CLEAN['x'] = false; if (isset($_POST['x'])) { if (0 == 1*$_POST['x']) { $_CLEAN['x'] = 0; } else

Re: [PHP] shortest possible check: field is set, integer or 0

2005-12-01 Thread Jochem Maas
Steve Edberg wrote: Only problem with intval() is that it returns 0 (a valid value) on I knew that. :-) failure, so we need to check for 0 first. Adding more secure checks do we? given that FALSE casts to 0. would make this more than just a one-liner, eg; $_CLEAN['x'] = false; if

Re: [PHP] shortest possible check: field is set, integer or 0

2005-12-01 Thread Steve Edberg
At 5:30 PM +0100 12/1/05, Jochem Maas wrote: Steve Edberg wrote: Only problem with intval() is that it returns 0 (a valid value) on I knew that. :-) I figured so, but I thought I'd make it explicit for the mailing list... failure, so we need to check for 0 first. Adding more secure checks

[PHP] shortest possible check: field is set, integer or 0

2005-11-30 Thread Chris Lott
What is the shortest possible check to ensure that a field coming from a form as a text type input is either a positive integer or 0, but that also accepts/converts 1.0 or 5.00 as input? c -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] shortest possible check: field is set, integer or 0

2005-11-30 Thread Richard Lynch
On Wed, November 30, 2005 5:10 pm, Chris Lott wrote: What is the shortest possible check to ensure that a field coming from a form as a text type input is either a positive integer or 0, but that also accepts/converts 1.0 or 5.00 as input? This might be good enough: if (isset($_POST['x'])){

Re: [PHP] shortest possible check: field is set, integer or 0

2005-11-30 Thread Ray Hauge
Richard Lynch wrote: On Wed, November 30, 2005 5:10 pm, Chris Lott wrote: What is the shortest possible check to ensure that a field coming from a form as a text type input is either a positive integer or 0, but that also accepts/converts 1.0 or 5.00 as input? This might be good