You are here: Re: My php source code do not work « PHP Programming Language « IT news, forums, messages
Re: My php source code do not work

Posted by Erwin Moller on 05/29/07 16:52

Pablo wrote:

> Hi at all
> this code it'ld stop and exit if the user do not entered $dbf but it do
> not work
> Why?
>
> if (!isset($_GET['dbf']) || (isset($_GET['dbf']) && trim($_GET['dbf']) ==
> ''))
> {header('Location: http://www.pablo.es/index.php');
> exit();}

Hi,

Look at the logic:
if
(!isset($_GET['dbf']) || (isset($_GET['dbf']) && trim($_GET['dbf'])== ''))

My guess is you ment:
1) Demand that $_GET['dbf'] is set.
2) And if set, it must contain something (not empty string)

The above mixes the || and && is a strange way.

So try this:
if ( (isset($_GET['dbf']) && (trim($_GET['dbf']) != '')){
// OK
} else {
// Not OK
// header and exit.
}

You do not need the second isset-test this way.
When PHP evaluates the first part (isset($_GET['dbf']) to false and sees the
AND-logic operator && it doesn't even try to evaluate that, because the
if-statement can never evaluate to true.

Regards,
Erwin Moller

 

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

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