Submitting multiple inputs w. same name not returning array
Posted: Mon Mar 23, 2009 12:10 pm
I'm banging my head against the wall because code that worked fine last week is no longer working.
I have a list of time records. Each time record has a unique id which I submit along with all the other data on update. The input for the time id is called timeid[] on each row. The names are not unique and this is the way I need it to be.
When I submit the rows I (should) get an array of values for timeid which I then loop through. This used to work fine. I've been using this technique for many years on many different websites including this one. If I take away the square brackets then it only grabs the last input with that name on submit.
This morning I come into work and it's no longer working. The code is not finding an array upon submit and therefore is not looping through my rows and updating data.
When I run the following loop to see what values I'm getting in my $_POST
I get the word "Array" for each value. I'm not sure if that's right but it seems promising.
However, when I do the following:
I get "Is not an Array" every time.
When I do this:
It returns a count of 1.
When I do this:
It returns the letter "A", which is obviously the first letter of the word "Array".
If anybody can give me a clue it would be much appreciated.
Now, I did make some changes to the site but I don't see how this could cause PHP to no longer recognize arrays.
The list in question (the list of time enries) is being generated by a function. I added some code to this function that prints some images and divs if certain conditions are true. I did not change the time id input or any other inputs. All I did was add more code to this function. The new code works like a charm by the way. Is there a point at which a function gets too large that causes PHP to go stupid?
I have a list of time records. Each time record has a unique id which I submit along with all the other data on update. The input for the time id is called timeid[] on each row. The names are not unique and this is the way I need it to be.
When I submit the rows I (should) get an array of values for timeid which I then loop through. This used to work fine. I've been using this technique for many years on many different websites including this one. If I take away the square brackets then it only grabs the last input with that name on submit.
This morning I come into work and it's no longer working. The code is not finding an array upon submit and therefore is not looping through my rows and updating data.
When I run the following loop to see what values I'm getting in my $_POST
Code: Select all
foreach($_POST as $var => $value){
echo $var . ' : ' . $value . "<br>";
}However, when I do the following:
Code: Select all
echo is_array($_POST[timeid]) ? '<br>Is an Array' : '<br> Is not an Array';When I do this:
Code: Select all
echo count($_POST[timeid])When I do this:
Code: Select all
echo $_POST[timeid][0]If anybody can give me a clue it would be much appreciated.
Now, I did make some changes to the site but I don't see how this could cause PHP to no longer recognize arrays.
The list in question (the list of time enries) is being generated by a function. I added some code to this function that prints some images and divs if certain conditions are true. I did not change the time id input or any other inputs. All I did was add more code to this function. The new code works like a charm by the way. Is there a point at which a function gets too large that causes PHP to go stupid?