I have some code that worked perfectly a few hours ago, and for some reason it is nbow totally useless.
I have scoured the web for hours trying to work out why I am getting a Notice: array to string conversion error.
On a previous page I post and array of team names to the page where the error message is created.
If I var_dump the array (which is called $teams) all the data is there, every team name in an array.
array(1) { [0]=> array(12) { [0]=> string(6) "Team a" [1]=> string(6) "Team a" [2]=> string(6) "Team a" [3]=> string(6) "Team b" [4]=> string(6) "Team b" [5]=> string(6) "Team b" [6]=> string(6) "Team c" [7]=> string(6) "Team c" [8]=> string(6) "Team c" [9]=> string(6) "Team d" [10]=> string(6) "Team d" [11]=> string(6) "Team d" } }
Note, the team names are repeated as this is a fixture list, so each team plays each team.
However, the array to string conversion error is occuring in my query.
So, at the top of the page I create an array from the data posted like this...
$team[]=$_POST['team'];
then in my query I run a for loop and run the query, summarised as follows;
$count=count($team);
for($i=0;$i<$count;$i++ {
$query=$database->query("UPDATE pool_a SET ......where team_name='$team[$i]')"
I am so confused, I did a bit of editing earlier to try to add further queries to produce tables for pool_b, pool_c etc but I scrapped them and I am sure the code is as it was this morning.
Any help would be much appreciated.
Thanks