Re: recover values independently of GET or POST used

From: Date: Tue, 15 Sep 2009 03:25:36 +0000
Subject: Re: recover values independently of GET or POST used
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-46506@lists.php.net to get a copy of this message
buzon@alejandro.ceballos.info wrote:
I am using some expressions to load the value of a parameter when called, independently if used GET or POST method, using something like: <?php $mydata = (isset($_GET["mydata"])) ? $_GET["mydata"] : (isset($_POST["mydata"])) ? $_POST["mydata"] : 0; echo $mydata; ?> The problem occurs with above code if I call it like: thispage.php?mydata=something , the answer is null (not even '0').
You probably need extra ()'s around the post check: $mydata = (isset($_GET["mydata"])) ? $_GET["mydata"] : ((isset($_POST["mydata"])) ? $_POST["mydata"] : 0); Though that's hard to read - I'd suggest going back to basics because when you revisit this code in a few months time, are you going to understand it? -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.db (#46506) next »