Re: 2 ifs embedded?

From: Date: Fri, 31 Jul 2009 16:13:15 +0000
Subject: Re: 2 ifs embedded?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-296126@lists.php.net to get a copy of this message
Miller, Terion wrote: > > > On 7/31/09 11:03 AM, "Miller, Terion" <tmiller@springfi.gannett.com> wrote: > > > > > On 7/31/09 10:54 AM, "Jim Lucas" <lists@cmsws.com> wrote: > > Miller, Terion wrote: >> >> On 7/31/09 10:14 AM, "Bastien Koert" <phpster@gmail.com> wrote: >> >> On Fri, Jul 31, 2009 at 10:59 AM, Miller, >> Terion<tmiller@springfi.gannett.com> wrote: >>> >>> On 7/31/09 9:53 AM, "Bastien Koert" <phpster@gmail.com> wrote: >>> >>> On Fri, Jul 31, 2009 at 10:28 AM, Miller, >>> Terion<tmiller@springfi.gannett.com> wrote: >>>> >>>> On 7/31/09 8:58 AM, "m0s" <dev@lenss.nl> wrote: >>>> >>>> (!empty($row['notes']) && IsAlpha($row['notes'])) >>>> >>>> I tried that and this one: >>>> >>>> If (!empty($row['notes']) && >>>> ctype_alpha($row['notes'])) >>>> >>>> It didn't display the notes at all... >>>> >>>> And this one...doesn't display if the field has a 0 in it but I still need it >>>> to? >>>> >>>> If (!empty($row['critical']) && >>>> ctype_alnum($row['critical'])) >>>> >>>> -- >>>> PHP General Mailing List (http://www.php.net/) >>>> To unsubscribe, visit: http://www.php.net/unsub.php >>>> >>>> >>> Hey Teri, >>> Could the return from the db have a space or something in the value? Perhaps >>> >>> If (!empty($row['critical']) && >>> ctype_alnum((int)$row['critical'])) >>> >>> might work >>> >>> >>> -- >>> >>> Bastien >>> >>> Cat, the other other white meat >>> >>> >>> It's got me stumped, tried it and it still will not echo if the field has a 0 in >>> it: >>> >>> If (!empty($row['critical']) && >>> ctype_alnum((int)$row['critical'])){ echo(" Critical violations found: ". >>> $row['critical'] .". "); >>> >> If you echo it out what is the value? >> >> echo "[".$row['critical']."]"; >> >> what do you get? >> >> -- >> >> Bastien >> >> Cat, the other other white meat >> >> If I echo it I get the int that is in the field from the db fine...so it's something >> with my statement? >> > > That all depends on WHAT it is you are getting. > > Can you tell us WHAT you are getting? Not simply that "I get the int > that is in the field from the db". We don't have any idea what that > value is. Only you know that... > > > Numbers are in that field ... So I'm getting 0, 1, 2 etc however many violations there > are, so why doesn't this work? > > If (ctype_alnum((int)$row['critical'])){ echo(" Critical violations > found: ". $row['critical'] .". "); > So, the only thing you will see is a number? Correct? What is the range that the number will fall between? And, does zero mean anything different then 1, 2, 3... If, all you want to do is make sure that $row['critical'] is a number and the value is within a range of numbers, so this. if ( isset($row['critical']) && is_numeric($row['critical']) && in_array($row['critical'], range(0, 200)) } { ... }

« previous php.general (#296126) next »