By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,723 Members | 1,876 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,723 IT Pros & Developers. It's quick & easy.

Warning: Invalid argument supplied for foreach()

P: 2
Hi All,

May i know how to rectify the following php error? Thanks folks

Warning: Invalid argument supplied for foreach() in /home/alan/do_add-user.php on line 36

do_add-user.php.php on line 304:
$project_array = $_POST[Project];


304 foreach($project_array as $project){
$sql3 = "INSERT INTO Mapping SET user_id='$uid', project_id='$project'";
$result3 = @mysql_query($sql3,$connection) or die(mysql_error());

}
Feb 12 '08 #1
Share this Question
Share on Google+
1 Reply


rpnew
100+
P: 188
Hi All,

May i know how to rectify the following php error? Thanks folks

Warning: Invalid argument supplied for foreach() in /home/alan/do_add-user.php on line 36

do_add-user.php.php on line 304:
$project_array = $_POST[Project];

304 foreach($project_array as $project){
$sql3 = "INSERT INTO Mapping SET user_id='$uid', project_id='$project'";
$result3 = @mysql_query($sql3,$connection) or die(mysql_error());

}
Hi,
Here you are trying to use normal variable in foreach loop.... instead of that try this......(if your 'Project' variable is an array...)
[PHP]
foreach($_POST['Project'] as $project){
$sql3 = "INSERT INTO Mapping SET user_id='$uid', project_id='$project'";
$result3 = @mysql_query($sql3,$connection) or die(mysql_error());

}
[/PHP]
Regards,
RP
Feb 12 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.