
November 17th, 2004
03:04 AM
Notice: Undefined index:
i keep getting the following error
Notice: Undefined index: act in D:\web\wwwroot\plat\index.php on line 32
[QUOTE]$page = array(
'idx' => 'news',
'join' => 'join'
);
$_REQUEST['act'] = $_REQUEST['act'] == '' ? "idx" : $_REQUEST['act'];
if (!isset($page[ $_REQUEST['act'] ]) )
{
$_REQUEST['act'] = 'idx';
}
require $root.'/sources/'.$page[ $_REQUEST['act'] ].'.'.EXT;[/QUOTE]
that is the code for it.
how can i resolve this without turning of error reporting

November 17th, 2004
05:21 AM
Neverside Newbie
Status: Offline!
Are you trying to do query strings... like index.php?type=this&something=that?
And which line is line 32?
Please answer both questions.

November 17th, 2004
07:59 AM
That message means that 'act' is not a known index in the $_REQUEST array, meaning that it hasn't been succesfully set to a value.
That probably means the part of the code that causes trouble is this:
<?php
$_REQUEST['act'] = $_REQUEST['act'] == '' ? "idx" : $_REQUEST['act'];
?>
If that's the problem, then the code that this variable is used for shouldn't work. But i've had some weird problems myself with superglobal arrays, it could have something to do with the setup of php. On a host i use for testing when i have no other options, i get the same "undefined index " error while the variable actually does exist and it can be used properly. In this case, i used error suppression by putting a @ in front of the statement.

November 17th, 2004
09:07 AM
So what's up :)
Status: Offline!
I would suggest using $_GET rather than $_REQUEST 
___________________
"¿Por qué buscais la felicidad, oh, mortales, fuera de vosotros mismos?"
~Boecio

November 17th, 2004
11:02 AM
whoa, wtf?
Status: Offline!
www.php.net/isset
<?php
$_REQUEST['act'] = isset($_REQUEST['act']) ? $_REQUEST['act']: "idx" ;
?>
that should do what you want.
___________________
Fomerly known as lasnaranjas. Holler.


November 18th, 2004
07:02 AM
thinking of something witty to put here
Status: Offline!
Originally posted by Alekz
I would suggest using $_GET rather than $_REQUEST
Me too. $_REQUEST isn't much more secure than registered globals.

November 19th, 2004
10:53 AM
whoa, wtf?
Status: Offline!
Originally posted by Radley
Me too. $_REQUEST isn't much more secure than registered globals.
*sigh*
$_GET/$_POST is preferred, but they're essentially the same thing. Register globals lets you set an arbitrary amount of variables/values in a person's script. You can't do that with $_REQUEST.
-Jerome
___________________
Fomerly known as lasnaranjas. Holler.


November 19th, 2004
11:03 AM
thinking of something witty to put here
Status: Offline!
Yes, but another one of the flaws was that POST and GET data are invisibly interchanged. Of course you should still validate all of your data on the server, but it's nice to have good habits.
By the way, save the attitude please.
Last edited by Rad, November 19th, 2004 11:25 AM (Edited 1 times)

November 20th, 2004
10:48 AM
whoa, wtf?
Status: Offline!
Originally posted by Radley
Yes, but another one of the flaws was that POST and GET data are invisibly interchanged. Of course you should still validate all of your data on the server, but it's nice to have good habits.
By the way, save the attitude please.
That shouldn't really cause an issue in your code. As long as your checking the data and it can't leak, there's no reason why you can't get it through a different method.
By the way, there wasn't an attitude, merely making a statement.
___________________
Fomerly known as lasnaranjas. Holler.


November 20th, 2004
02:38 PM
So what's up :)
Status: Offline!
I think also that you can carry less data in GET than in POST 
___________________
"¿Por qué buscais la felicidad, oh, mortales, fuera de vosotros mismos?"
~Boecio