astratt Posted August 8, 2008 Share Posted August 8, 2008 Can someone please take a look at this and tell me what I am doing wrong in this for each statement. I am getting this error: Warning: Invalid argument supplied for foreach() below is a snippet of my code: $last_id = mysql_insert_id (); // INSERT TeamMember IDs if (!(count($userId) == 1 && $userId[0] == "")) {//dont save if first (blank) option is selected foreach($_POST[$userId] as $id){ $qry_insert = "INSERT INTO tblTeamMembers (ProjectID, UserID) VALUES('$last_id','$userId')"; $qry_insert_rs = $connector->query($qry_insert) or die(mysql_error()); } } Any help would be greatly appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/118767-foreach-error/ Share on other sites More sharing options...
kenrbnsn Posted August 8, 2008 Share Posted August 8, 2008 Is $_POST[$userId] an array? Please show us the form that generates the data. Ken Link to comment https://forums.phpfreaks.com/topic/118767-foreach-error/#findComment-611511 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.