Argument should be an array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • assgar
    New Member
    • Aug 2006
    • 41

    Argument should be an array

    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]
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    I hope the following code statement is a type\
    Code:
    $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);
    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:

    Comment

    • assgar
      New Member
      • Aug 2006
      • 41

      #3
      Originally posted by ronverdonk
      I hope the following code statement is a type\
      Code:
      $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);
      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?

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        I will.

        Ronald :cool:

        Comment

        Working...