471,071 Members | 1,230 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

Warning: Invalid argument supplied for foreach()

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
1 1183
rpnew
188 100+
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.

Similar topics

1 post views Thread by custom3 | last post: by
1 post views Thread by BryanA | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.