Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

undefined index

Status
Not open for further replies.

lardum

IS-IT--Management
Apr 26, 2000
462
SE
I receive the following error in my apache log:
PHP Notice: Undefined index: id in PHP-file

The line it's complaining about is:

$id = $_REQUEST['id'];

Anyone have any ideas?
 
is $_REQUEST['id'] being sent, or has it not been sent at the point you get the error?

I guess:
if (isset($_REQUEST['id']))
{
$id = $_REQUEST['id'];
}

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
I'm not quite sure. I'm very new to PHP and i received a site that was earlier on PHP4+linux, now i run it on PHP5 and Win2K. I've managed to replace a lot of other variables that has been replaced with new names in PHP5. However now i'm stuck with this error message in my errorlog.

The php file itself is a top frame of the page. Everything looks fine on the page, but this message always appears. The line it complains on is line 3 so i think it's supposed to receive it from another file.
 
$_REQUEST means it should come either from a address line (get method), post (method) or a cookie. That means that information from id was supposedly sent to the page in question. Usually, this is found in forms, when the same phyisical file contains scripts that show and process the form. If form was submitted, the id is there, if not it is not.

The "error" you're getting is not an error but a warning. PHP can still run, but it is telling you that it cannot find anything where you're looking. So, to get rid of it, do a test that KarveR pointed out -- this will bypass the variable setting if the thing does not exist and your warning will go away.

KarveR's solution is also best coding practice. It is always smart to check if variables exist before you start manipulating with them.
 
thanks for your replies. i know that the id is passed from an address line.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top