You are here: Re: testing the condition of a pair of fields « All PHP « IT news, forums, messages
Re: testing the condition of a pair of fields

Posted by kay on 10/10/85 11:51

Ian Davies написав:
> >This way, the condition only applies when both sub-conditions are true
> (both
> >fields are non-empty);
>
> Thats exactly what I want only one field should have something in it and
> both fields should NOT be empty at the same time. But it doesnt work.
>
> Ian
>
>
> "Janwillem Borleffs" <jw@jwscripts.com> wrote in message
> news:44a0642c$0$24649$dbd4b001@news.euronet.nl...
> > Ian Davies wrote:
> > > if ((isset($_POST['Link']) && $_POST['Link'] !=='') &&
> > > (isset($_POST['uploadedfile']) && $_POST['uploadedfile'] !=='')) {
> > > $error_msg.="<br>You can't select to upload a link and a file at the
> > > same time.";
> > >
> >
> > This way, the condition only applies when both sub-conditions are true
> (both
> > fields are non-empty); replace the && between the sub-conditions with ||
> >
> > if ((isset($v) && $v !=='') || (isset($v2) && $v2 !=='')) {
> > ...
> > }
> >
> > > curiously the following works
> > >
> > > if(empty($_POST['Link']) || $_POST['Link'] ='' &&
> > > empty($_FILES['uploadedfile']) || $_FILES['uploadedfile'] ='') {
> > > $error_msg.="<br>You didn't select whether to upload a link or a
> > > file."; }
> > >
> >
> > That's because with the ||, only one test has to pass. Also note that you
> > are not compatring values (==) but assigning them (=).
> >
> >
> > JW
> >
> >
> >

The boolean result of initialization the variables in 'if' condition
is always 'true' so the code like

if ( (...||...||...||$a=''||...) && (...||...||...||$b=''||...)&&
..... (...||...||...||$z=''||...))

will be always true as Janwillem Borleffs mentioned.


Maybe you meant $Post['Link']=='' in your code?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация