Jump to content

Getting this error: "Notice: Undefined index:"


Recommended Posts

This has nothing to do with the installation fo WAMP....

 

 

Anyway....  What it means is that a referenced index of an array does not exist.

 

The following code, for example, would generate an error:

<?php

$a = array('str1' => 'Hello', 'str2' => 'World');

//all of these would throw notices

echo $a['str3'];
echo $a[2];
echo $a['omgwhatisthis'];

?>

 

The way around it?  isset() (or if you need to check the existance even of null values, array_key_exists()).

 

Example:

 

if(isset($a[$var])) echo $a[$var];
if(array_key_exists($var, $a)) echo $a[$var];

Hi,

 

Thanks for your reply...

 

But my another machine is not showing this error....

Same Windows 2003 server..

 

Same code produces Error in one machine and not showing this error in other machine...

 

That's why i confused about installation...

 

Any other way ???

 

The other machine most probably has display_errors disabled or error_reporting is set to ignore notices, this is why you dont get the underfined index message displayed.

 

This also does not mean that your code is running fine on the other machine as no errors are displayed, they will be logged in your servers error log though.

There are other settings, such as register_globals or even short open tags that could cause data to exist or code to be parsed on one server and not another.

 

You would need to post the code that is generating the error and the whole error message to get specific help with your problem.

hi Kumar,

            though posting the code snippet here will get you the exact solution to this problem but in the mean time please try this:-

 

set error_reporting=6143 in php.ini and then restart you wamp server and check the same code in your no problem machine.This will show you the error on  your second machine also and then post the code snippet in order to get the correct solution for it or you can just turn off the notices on both the machines by setting error_reporting=1, which is not recomended idealy.

 

 

 

Best of Luck

RV

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.