473,769 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Argument should be an array

41 New Member
Hi

I thought I had resolved this problem but I am intermittently
the receving the warnings below.

This code consist of a 1) HTML form, 2) a display function on the HTML form and
3) a process to manage the form input.

Can you show me what I am doing wrong and or how to correct it ?

<b>Message received:</b>

Warning: array_filter() [function.array-filter]:
The first argument should be an array in D:\search_proce ss.php on line 155

Warning: array_filter() [function.array-filter]:
The first argument should be an array in D:\search_proce ss.php on line 156

Warning: array_filter() [function.array-filter]:
The first argument should be an array in D:\search_proce ss.php on line 171

Warning: array_filter() [function.array-filter]:
The first argument should be an array in D:\search_proce ss.php on line 172


<b>Note: I have proveded only a small portion of the related code. </b>




[html]
<!--/**FORM**/-->
{//function start

//for loop start
{


echo"<tr height=\"10\">
<td width=\"4%\" bgcolor=\"#fff8 dc\" align=\"center\ ">
<input type=\"checkbox \" name=\"fee1_cho ice[$i]\" value=\"$code_i d\"></td>
<td width=\"7%\" bgcolor=\"#fff8 dc\" ><span class=\"style20 \"><strong>$fee 1_code</strong></span></td>
<td width=\"3%\" bgcolor=\"$bgco lor\" height=\"10\">
<input type=\"text\" name=\"fee1_uni t[$i]\" size=\"1\" maxlength=\"2\" value =\"$fee1_unit \"/>
</td>
<td width=\"79%\" bgcolor=\"$bgco lor\" class=\"style20 \"> $description </td>
<td width=\"6%\" align=\"left\"> $s_fee</td>\n";
echo"</tr>\n";

}//end of loop

//assign all arrays into single array for the return statement
$all_array = array(fee_choic e, fee_unit, fee_money, fee1_choice, fee1_unit, fee1_fee, fee2_choice, fee2_code, fee2_unit, fee2_describe, fee2_money, fee3_choice, fee3_code, fee3_unit, fee3_describe, fee3_money);

//return array from function
return ($all_array);

}//end of function

//unpack returned array
list($fee_choic e, $fee_unit, $fee_money, $fee1_choice, $fee1_unit, $fee1_fee, $fee2_choice, $fee2_code, $fee2_unit, $fee2_describe, $fee2_money, $fee3_choice, $fee3_code, $fee3_unit, $fee3_describe, $fee3_money )= $all_array;

[/html]



[php]
<?php
/**PROCESS**/

/**data from form**/
$fee_unit = $_POST['fee_unit'];//array with the number of units
$fee_money = $_POST['fee_money'];//array selected fee

//filter blank indexes
$fee_unit = array_filter($f ee_unit); //line 155
$fee_money = array_filter($f ee_money); //line 156


/**data from form**/
$fee1_unit = $_POST['fee1_unit'];//array with the number of units
$fee1_money = $_POST['fee1_money'];//array selected fee


//filter blank indexes
$fee1_unit = array_filter($f ee1_unit); //line 171
$fee1_money = array_filter($f ee1_money);//line 172

/** get array contents for insertion**/
$indices2 = array_keys($cod e1_id);
foreach($indice s2 as $index2)
{
//individual value validation from 3 arrays
$code1_id[$index2];
$fee1_unit[$index2];
$fee1_money[$index2];

//validate unit
$field_unit = $fee1_unit[$index2];//assign field to array for function
check_unit_fiel d($field_unit);//funtion to validate user entered numbers or message sent


//insert statement goes here

}
?>

[/php]


I have added the code below to the process to get rid of
the errors but this creates another problem where the
for loop can't extract the data from the arrays.

[php]

//create array A
$fee_unit = array($fee_unit );
$fee_money = array($fee_mone y);


//create array B
$fee1_unit = array($fee1_uni t);
$fee1_money = array($fee1_mon ey);

[/php]
Dec 6 '06 #1
3 3738
ronverdonk
4,258 Recognized Expert Specialist
I hope the following code statement is a type\
Expand|Select|Wrap|Line Numbers
  1. $all_array = array(fee_choice, fee_unit, fee_money, fee1_choice, fee1_unit, fee1_fee, fee2_choice, fee2_code, fee2_unit, fee2_describe, fee2_money, fee3_choice, fee3_code, fee3_unit, fee3_describe, fee3_money);
  2.  
if not, what are you addressing here? Not php variables!

Have you printed (print_r($_POST ) the POST array to see what is the construction of e.g. $_POST['fee_unit'] ?

Ronald :cool:
Dec 6 '06 #2
assgar
41 New Member
I hope the following code statement is a type\
Expand|Select|Wrap|Line Numbers
  1. $all_array = array(fee_choice, fee_unit, fee_money, fee1_choice, fee1_unit, fee1_fee, fee2_choice, fee2_code, fee2_unit, fee2_describe, fee2_money, fee3_choice, fee3_code, fee3_unit, fee3_describe, fee3_money);
  2.  
if not, what are you addressing here? Not php variables!

Have you printed (print_r($_POST ) the POST array to see what is the construction of e.g. $_POST['fee_unit'] ?

Ronald :cool:
Hi Ron

Thanks for responding.

I altered the values assigned to $all_array used by the return starement.
This seems to be working and I have not received any error or warning messages yet.

Working change

[php]
$all_array = array($fee_choi ce, $fee_unit, $fee_money, $fee1_choice, $fee1_unit, $fee1_fee, $fee2_choice, $fee2_code, $fee2_unit, $fee2_describe, $fee2_money, $fee3_choice, $fee3_code, $fee3_unit, $fee3_describe, $fee3_money);

[/php]

I think this can be considered resolved, unless you think other wise.

Who marks the discussion as resolved?
Dec 7 '06 #3
ronverdonk
4,258 Recognized Expert Specialist
I will.

Ronald :cool:
Dec 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3969
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer http://sourceforge.net/projects/cpp-perfometer http://alexvn.freeservers.com/s1/perfometer.html
1
7676
by: Mark Dicken | last post by:
Hi All I have found the following Microsoft Technet 'Q' Article :- Q210368 -ACC2000: How to Pass an Array as an Argument to a Procedure (I've also copied and pasted the whole contents into the bottom of this email)
12
5994
by: Uncle | last post by:
I am an untrained hobbyist. Everything about programming I have learned from the internet. Thank you all for your gracious support. This is what I have: #define CONST_CHAR 0 void some_func( char* arg, int len ) { // stuff }
23
2180
by: Daniel Rudy | last post by:
Hello, I'm trying to learn how command line arguments are handled in C. The following code segment that I wrote as a test program compiles, but when I try to run it, it core dumps. This is under a FreeBSD environment. What am I doing wrong here? /* just echos the command line arguments onto the screen
7
8134
by: bowlderster | last post by:
Hello,all. I want to get the array size in a function, and the array is an argument of the function. I try the following code. /*************************************** */ #include<stdio.h> #include<stdlib.h> #include<math.h>
6
6934
by: virgincita schmidtmann | last post by:
Good evening, I would like to pass the size of an array from the commandline. int main(int argc, int *argv) { .... max=*argv; int list; ....
17
2099
by: Klaas Vantournhout | last post by:
Hi all, I was wondering if it is possible if you can check in a function if one of the arguments is temporary. What I mean is the following. A is a class, foo is a function returning a class and bar is a function using A is an argument returning something else class A;
12
2069
by: lorlarz | last post by:
In the code sample below, how are arguments a legitimate argument to Array.slice? Function.prototype.bind = function(){ var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift(); return function(){ return fn.apply(object, args.concat(Array.prototype.slice.call(arguments)));
4
6339
by: mattehz | last post by:
Hey there, I am trying to upload old source files and came across these errors: Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_html.php on line 59 Notice: Undefined index: args in /home/mattehz/public_html/acssr/trunk/inc_error.php on line 92 Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_error.php on line 92
0
9579
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
9416
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10199
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
10032
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...
1
9979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9849
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
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5433
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.