Questions tagged [undefined-index]

An index is undefined if it is not part of the array being accessed. Use this tag for questions regarding behaviour of undefined indexes or when you see undefined indexes where you don't expect them.

This notice appears when you try to access an undefined index of an array. These commonly appear when working with $_POST, $_GET or $_SESSION variables in PHP.

Use this tag for questions about the behaviour of undefined indexes or when you see undefined indexes where you don't expect them.

276 questions
1353
votes
29 answers

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

I'm running a PHP script and continue to receive errors like: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php on line 10 Notice: Undefined index: my_index C:\wamp\www\mypath\index.php on line 11 Warning: Undefined array…
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
49
votes
10 answers

Undefined index with $_POST

I am trying to relearn some PHP basics for making a simple login script, however I get an error I have not received before(I made the same script a little over a year ago and never had this error. I simplified the code as much as I could to test to…
Xander Luciano
  • 3,753
  • 7
  • 32
  • 53
19
votes
2 answers

Undefined index error upon $em->clear() in Symfony2

I have written a Symfony command to import some data from an API. It works but the problem is my PHP memory usage increases when I insert a big JSON in my database. And my unitOfWork increases by '2' to after each activty import. I have already…
psylo66
  • 608
  • 11
  • 26
13
votes
1 answer

Why does accessing array index on boolean value does not raise any kind of error?

When I try to access an array by key which is not exists in this array, php will raise "undefined index" notice error. When I try to do the same on strings, "Illegal string offset " warning is raised. This is an expected behavior and I know how to…
Samel Vhatargh
  • 235
  • 1
  • 9
10
votes
1 answer

PHPMyAdmin Undefined Index: Rows

I'm receiving the error below when using phpMyAdmin. It's occurring every time I create any table. Notice in ./libraries/structure.lib.php#1881 Undefined index: Rows Backtrace ./libraries/structure.lib.php#2382:…
Sawyer05
  • 1,604
  • 2
  • 22
  • 37
6
votes
14 answers

Javascript: How to clear undefined values from an array

I'm trying to loop through an array and delete and skip the elements until only one is existing. i've tried splicing but it messes up my loop because the element from arr[1] then becomes arr[0] etc. Let's say there are 10 people. I'd like to remove…
KT.
  • 571
  • 3
  • 6
  • 19
5
votes
3 answers

PHP: Undefined index even after checking IsSet

I have read the other questions, none have answered nor helped me. Here is my issue, I have an object/array which contains a property which is also an object/array. I have successfully accessed similar properties before…
AnimaSola
  • 7,146
  • 14
  • 43
  • 62
4
votes
1 answer

Why does Doctrine try to duplicate a Many-To-Many relationship even though I check if it exists beforehand? And why does it randomly crash on flush?

I'm having a really hard time with Doctrine failing to work as expected. What my code tries to do. I'm writing a CLI command in my Symfony 3 web application that is supposed to tidy up a tags table in my database. There are Actors and there are…
4
votes
3 answers

$_POST not working. "Notice: Undefined index: username..."

Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” So, I am currently learning PHP and was reading on a book about the md5 function for passwords, so I decided to give it a try and see how it goes. I also decided…
blacblu
  • 297
  • 2
  • 6
  • 19
3
votes
3 answers

How can I fix this undefined index error? Jquery Ajax to PHP

I'm using Jquery, Ajax and PHP to try and send a variable to be written in a mysql database. The Ajax request is being made but the variable is not being picked up by the php. I don't know why this is the case. Using firebug and console.log() I can…
TryHarder
  • 2,704
  • 8
  • 47
  • 65
3
votes
2 answers

Kohana: Undefined index when there is not one

I'm using Kohana 3.1 and I'm getting a very strange error. The Kohana POST handler seems to think that there's an undefined index when there is not one. Inside of a controller class: $post = $this->request->post(); var_dump(isset($post['jid']));…
Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
3
votes
2 answers

Undefined or defined index ? Decide

I have strange problem. Line 61: $this->_currentRoute = Default_Model_Routes::getInstance()->getCurrentRoute(); .......... other code .......... Line 86: var_dump(isset($this->_currentRoute['url'])); Line 87:…
grongor
  • 1,305
  • 1
  • 13
  • 26
3
votes
1 answer

PDO throws an Notice: Undefined index when using fetchAll in a WHILE loop

I'm new in the PHP world and I need a bit of help here. I'm trying to extract a data from database, I'm using PDO to do it. I have the following PHP code without success, throwing back error notice: $pairingsistem='1';…
MK Smith
  • 111
  • 10
3
votes
2 answers

How can I check if a value is undef in Perl?

Best asked by an example: my $var1=1; my $var2; my $var3=3; # say "at least one undef" if at least one of $var1, $var2, $var3 is undef Obviously I can explicitly loop and do that, but I always like to find one liners that achieve the same result.
David B
  • 29,258
  • 50
  • 133
  • 186
3
votes
1 answer

reason why sqlstate[hy093] error is happening? when all conditions are met

i'm trying to figure out whats wrong with this code i got from this forum basically i was trying to modify it and see if i could solve this error above which has also come with an undefined index error.my question is why the errors because all…
1
2 3
18 19