RE: [PHP] An if question

From: Date: Tue, 04 May 2004 09:03:14 +0000
Subject: RE: [PHP] An if question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-185282@lists.php.net to get a copy of this message
Hi, Nope that doesnt work. Allows everything to be added. I tried adding 0, 6,1 all are allowed Thanks for the help. Ian > -----Original Message----- > From: Brent Clark [mailto:bclark@equation.co.za] > Sent: 04 May 2004 10:50 AM > To: Ian Barnes; Php-General > Subject: Re: [PHP] An if question > > > > if($add){ > > if (!$rec or $rec>5) { > > $err='Invalid Level. Must be 0-5'; > > } else { > > printsomestuffhere > > } > > > > What happens is that it doesnt allow anything greater than 5 (Correct), > but > > it doesnt allow 0, it allowes 1,2,3,4&5 but not 0. The field > itself is set > > to only allow 1 character so they cant put a - sign in front > > > > Any idea how to allow 0 aswell? I have tried the following aswell, also > with > > no success: > > > > if ($add) { > > if (!$rec or $rec>5 or $rec<0) { > > $err='Invalid Level. Must be 0.5'; > > }else{ > > printsomestuffhere > > } > > Hi > try, hope it works > > if($add){ > if (preg_match("/[0-5]\d/",$rec)) { > $err='Invalid Level. Must be 0-5'; > } else { > printsomestuffhere > } > > Kind Regards > Brent Clark > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > >

« previous php.general (#185282) next »