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?

15
  • Show me the code and then I will tell you! Commented Jul 17, 2012 at 3:40
  • Some code examples would be good. Take a look at how other people ask questions. Maybe even search for your question first, rather than answer it. Commented Jul 17, 2012 at 3:43
  • i am sorry... wait i am giving the code... Commented Jul 17, 2012 at 3:47
  • @sayantan bagchi: it's not necessary. There are 4 answers here and billion similar questions in the right "Related" bar Commented Jul 17, 2012 at 3:54
  • 2
    @PhpMyCoder: I decided to get some easy rep points instead ;-P Commented Jul 17, 2012 at 3:57

4 Answers 4

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

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

4 Comments

i read that post... and i tried that bt its not helping that is why i have post mentioning this particular error...
@sayantan bagchi: what if you read some manual? php.net/isset
It's a standard PHP error. You're probably wondering why your form isn't submitting correctly, which is a different issue.
tahnk you so much... i will look into this...
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.