foreach function error

Discussion in 'PHP' started by kabucek, Dec 11, 2008.

  1. #1
    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
     
    kabucek, Dec 11, 2008 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,934
    Likes Received:
    4,563
    Best Answers:
    124
    Trophy Points:
    665
    #2
    You need to do some debugging and see why that variable isn't an array. Maybe a change to your input form? file?
     
    sarahk, Dec 11, 2008 IP
  3. misbah

    misbah Active Member

    Messages:
    265
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    68
    #3
    try this
    if(is_array($classSelectionArray))
    {
    	foreach ($classSelectionArray as $classID => $selectionStatus)
    	{
    		//your script
    	}
    }
    PHP:
     
    misbah, Dec 11, 2008 IP