Re: An if question

From: Date: Tue, 04 May 2004 10:56:24 +0000
Subject: Re: An if question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-185289@lists.php.net to get a copy of this message
Hi, Tuesday, May 4, 2004, 6:42:12 PM, you wrote: IB> Hi, IB> Here is a stupid question. IB> I am busy taking the input from a field to write it to a file. But the field IB> needs to be within a certain range (It must be from and including 0 - 5). IB> here is what I have: IB> if($add){ if (!$rec or $rec>>5) { IB> $err='Invalid Level. Must be 0-5'; IB> } else { IB> printsomestuffhere IB> } IB> What happens is that it doesnt allow anything greater than 5 (Correct), but IB> it doesnt allow 0, it allowes 1,2,3,4&5 but not 0. The field itself is set IB> to only allow 1 character so they cant put a - sign in front IB> Any idea how to allow 0 aswell? I have tried the following aswell, also with IB> no success: IB> if ($add) { if (!$rec or $rec>>5 or $rec<0) { IB> $err='Invalid Level. Must be 0.5'; IB> }else{ IB> printsomestuffhere IB> } IB> Thanks for the help IB> Ian if($rec<0 || $rec > 5) echo "Error $rec out of range <br>"; else echo "ok<br>"; -- regards, Tom

« previous php.general (#185289) next »