below is a function i have created but i am getting an error "Parse error: parse error, unexpected T_FOREACH in /home/www/functions.php on line 48"
line 48 is the begining of the foreach.
can anyone spot anything wrong? please help!
function addNewInvitedUsers ($addEventInvites,$eventId){
global $config;
//IF NEW USERS ARE TO BE ADDED
$array = explode(",", $addEventInvites);
foreach ($array as $emladdr){//THIS IS LINE 48 WHERE THE ERROR HAPPENS
$emladdr2 = trim($emladdr);
$sql_email_check = mysql_query("SELECT userId,emailAddress FROM users WHERE emailAddress='$emladdr2'");
$email_check = mysql_num_rows($sql_email_check);
if($email_check > 0 )
{
//user exists, so only add them to the usereventmap
$row = mysql_fetch_array($email_check);
$mapinsertquery = mysql_query("INSERT INTO usereventmap (userId,eventId) VALUES('$row[userId]','$eventId')") or die (mysql_error());
}else{
//user does not exist, add them to users table, get id, add to usereventmap
//add them to users
$regquery = mysql_query("INSERT INTO users (emailAddress,activated) VALUES ('$emladdr','0')")
or die ("Could not execute the query <!--{$query}-->");
$insertedId = mysql_insert_id();
$mapquery = mysql_query("INSERT INTO usereventmap (userId,eventId) VALUES('$insertedId','$eventId')") or die ("Could not execute the query <!--{$query}-->");
}
}//END foreach
}//end function