473,625 Members | 3,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Warning: Invalid argument supplied for foreach()

2 New Member
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($projec t_array as $project){
$sql3 = "INSERT INTO Mapping SET user_id='$uid', project_id='$pr oject'";
$result3 = @mysql_query($s ql3,$connection ) or die(mysql_error ());

}
Feb 12 '08 #1
1 1340
rpnew
188 New Member
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($projec t_array as $project){
$sql3 = "INSERT INTO Mapping SET user_id='$uid', project_id='$pr oject'";
$result3 = @mysql_query($s ql3,$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='$pr oject'";
$result3 = @mysql_query($s ql3,$connection ) or die(mysql_error ());

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

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

Similar topics

35
3208
by: jerrygarciuh | last post by:
Hi all, I was just wondering what popular opinion is on PHP giving this warning: Warning: Invalid argument supplied for foreach() in /home/boogerpic/public_html/my.php on line 6 when presented with an indefined variable. It makes sense to me to warn if an unacceptably defined var is passed but it
4
7827
by: Ryanlawrence1 | last post by:
Heya, I get these 2 errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 20 You have not entered all the fields Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 34 Sorry You failed to enter the correct old password I was wondering if anyone could help me, I have...
2
16920
by: techjohnny | last post by:
Error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/jplane/certcent/phpweb/quiz/index.php on line 20 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/jplane/certcent/phpweb/quiz/index.php on line 21 PHP CODE:
1
2702
by: lsmamadele | last post by:
I am getting the following error messages in my search: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on line 113 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on line 127 My code is below. Any help would be much appreciated. ...
2
10278
by: yogitha | last post by:
For the below code i am getting an error like : --------------------------------------------------------------- Warning: fread(): supplied argument is not a valid stream resource in D:\Public_Site\multifileupload\welcome_addfiles.php on line 28 ------------------------------------------------------------ i am trying many ways by giving diff arguments in fread() --------------------------------------------------- suggest me , wat error...
1
1530
by: custom3 | last post by:
Hello, I keep getting the following warning: "PHP Warning: Invalid argument supplied for foreach() in /home/csiexecu/public_html/modules/mod_mainmenu.php on line 339" I am a novice Joomla user that has just upgraded to 1.0.13. Can anyone give me direction on how or to whom I should go to fix this problem? The home page intermittently loads and times out. Thanks!
1
1629
by: BryanA | last post by:
Something seems to be wrong with this function and I can't figure out why it is failing. The error that it gives is; Invalid argument supplied for foreach() . function transposition($words){ foreach($words as $word){ for($x=0;$x<strlen($word)-1;$x++){ $results = substr($word, 0, $x) . $word . $word . substr($word, $x+2, strlen($word));
14
3340
by: rashgang | last post by:
i have dynamically created checkbox which will like yahoo mail if check box selected it will highlight a row but deleteall function is not working plz chek it function doDeleteAll($objArray){ foreach($objArray as $strkey=>$strValue) { $strDeleteId = $strValue; doDelete($strDeleteId);
21
2807
by: rashgang | last post by:
no check box selected when i gave delete all link the error is coming <?php include "includes/connection.php"; include "includes/Functions_category.php"; include "includes/functions_db.php"; $Strtitle="Category Management (Category Listing)";
0
8256
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8694
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8497
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7184
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6118
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.