hello @LL,
We have registration system and it was working on ok up till now.
When someone tries to register for our event there is an error message:
warning: invalid argument supplied for foreach() in /home/dir1/dir2/indexReg.php on line 5400
the code from line is:
foreach ($classSelectionArray as $classID => $selectionStatus)
and there is another message:
processTemplateArray: input is not a record array
Our php framework is hosted on webhosting company which has centos.
Is it possible that they run some update for php services which caused
bad interactions with "foreach" function? maybe older version of php or
some respository of it handles this differently ?
thanks
foreach function error
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: foreach function error
Sounds like they turned error reporting onto me, so the problem was mearly hidden. Hard to tell without seeing more, otherwise.
Generally, you should always check your array has atleast 1 row (and is in fact an array) before you iterate it.
isset() and/or count()
Generally, you should always check your array has atleast 1 row (and is in fact an array) before you iterate it.
isset() and/or count()
Re: foreach function error
i digged into the changes and revert old change and now I got similar error but for next lines:
Warning: Invalid argument supplied for foreach() in /home/dir1/dir2/indexRegEG.php on line 10833
code:
foreach ($tmpPeriodArray as $label=> $itemArray)
any suggestions?
Warning: Invalid argument supplied for foreach() in /home/dir1/dir2/indexRegEG.php on line 10833
code:
foreach ($tmpPeriodArray as $label=> $itemArray)
any suggestions?
Re: foreach function error
This is the error:
This is the code:Warning: Invalid argument supplied for foreach()
Obviously an invalid argument is supplied for the foreach loop? try checking the contents of $tmpPeriodArrayforeach ($tmpPeriodArray as $label=> $itemArray)
Code: Select all
var_dump($tmpPeriodArray);Re: foreach function error
i did that and there is "NULL" right before the error message.
any suggestions now?
thanks
any suggestions now?
thanks
Re: foreach function error
yep, a couple:
1. find out why the array is actually a NULL value (is it the result of a database query? maybe the query returns no results or is unsuccessful?)
2. Add a check before the foreach loop to make sure a NULL value doesn't get through:
1. find out why the array is actually a NULL value (is it the result of a database query? maybe the query returns no results or is unsuccessful?)
2. Add a check before the foreach loop to make sure a NULL value doesn't get through:
Code: Select all
if(is_array($tmpPeriodArray) ) {
// Process array in foreach loop
}Re: foreach function error
ok,
but how can i found out that ?
thanks
but how can i found out that ?
thanks