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];

Link to comment
Share on other sites

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 ???

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.