0

Possible Duplicate:
PHP: “Notice: Undefined variable” and “Notice: Undefined index”

When do we get this error?

Notice: Undefined index: submit in C:\wamp\www\sample.php on line 25

What is the exact meaning of this perticular error?

Community
  • 1
  • 1

4 Answers4

2

This means exactly what it says: you're addressing to an undefined index in an array

$arr = array();
echo $arr['foo'];

In the example above the array is empty but I tried to output 'foo' item value, which doesn't exist.

zerkms
  • 249,484
  • 69
  • 436
  • 539
1

It means you are trying to access a part of an arraythat isn't there.

If you have an array with 5 elements, you ca get to them via:

$array[0] through to $array[4]

But if you try $array[76] which doesn't exist, you will get an undefined Index error.

Fluffeh
  • 33,228
  • 16
  • 67
  • 80
1

You've probably got an array that you're accessing like $_POST['submit']. That error message is saying is the element 'submit' of the array doesn't exist, and it's throwing a warning.

You should check that array elements exist before using them isset() before you access them to avoid avoid the warning.

Edit: possible duplicate of this: Undefined index in PHP

Community
  • 1
  • 1
Jessedc
  • 12,320
  • 3
  • 50
  • 63
0

have you correctly mentioned the method in your form GET or POST ?? I think you are accessing/testing it without declaring it. Let me know if this is the case.

swapnesh
  • 26,318
  • 22
  • 94
  • 126