Re: Undefined index
| From: | Jim Lucas | Date: | Thu, 08 May 2003 16:07:13 +0000 |
| Subject: | Re: Undefined index | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146864@lists.php.net to get a copy of this message | ||
even better yet. this is how i have things.
<?php
function alternate(&$a, $b) {
return( $a = ( $a ? $a : $b ) );
}
then in your script do this.
echo $_GET['action']; // this will give you an error if you didn't pass
anything.
alternate($_GET['action'], 'action is now set to this string');
echo $_GET['action']; // this will echo 'action is now set to this string'
?>
now, if $_GET['action'] is blank, null, or not set at all, then it will set
$_GET['action'] to whatever you give as the second argument.
----- Original Message -----
From: "Jim Lucas" <phplist@zonedzero.net>
To: "caspar kennerdale" <caspar@thetuckshop.com>; <adam@cryptocomm.com>
Cc: <php-general@lists.php.net>
Sent: Thursday, May 08, 2003 9:00 AM
Subject: Re: [PHP] Undefined index
> yes, you can
>
> if ( empty($_GET['action']) )
> $_GET['action'] = '';
>
> Jim
> ----- Original Message -----
> From: "caspar kennerdale" <caspar@thetuckshop.com>
> To: <adam@cryptocomm.com>
> Cc: <php-general@lists.php.net>
> Sent: Wednesday, May 07, 2003 8:46 AM
> Subject: RE: [PHP] Undefined index
>
>
> > Thanks that 'covers' up the error message, but is there no way to give
the
> > index a value then when it is the default of a switch?
> >
> >
> > Cheers
> >
> > Caspar
> >
> >
> > Just at the top of your page, or in an include, put:
> >
> > error_reporting(E_ALL ^ E_NOTICE);
> >
> > (This is according to the error_reporting manual page).
> >
> >
> > On Wed, 2003-05-07 at 11:37, caspar kennerdale wrote:
> > > I have a basic switch defining the structure of my page. (see below)
> > >
> > > Whenever the default case is loaded I get a message that "action" is
an
> > > undefined index. I understand that this is because "action" has no
> value.
> > If
> > > I go to any of the other cases of my switch and thus giving "action" a
> > value
> > > then I do not get the message.
> > >
> > > How do I give action an initial value so this message does not appear
> > > initally? (I dont want to rely on isps turing messaging off!)
> > >
> > > If this isnt possible can you turn messaging off in .htaccess in the
> same
> > > way you can control register globals?
> > >
> > >
> > >
> > > <?php
> > >
> > > switch ($_GET['action']) {
> > > default:
> > > echo "<a
> > > href=\"index.php?action=Test&variable=yes\">test</a>";
> > >
> > > break;
> > >
> > > case "Test":
> > > $variable=$_GET["variable"];
> > > echo $variable;
> > > break;
> > >
> > > }
> > >
> > > ?>
> > --
> > Adam Voigt (adam@cryptocomm.com)
> > Linux/Unix Network Administrator
> > The Cryptocomm Group
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>