User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 426,140 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,698 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2143 | Replies: 0 | Solved
Reply
Join Date: Oct 2006
Posts: 76
Reputation: assgar is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
assgar assgar is offline Offline
Junior Poster in Training

Help Variable passed to each() is not an array

  #1  
Apr 19th, 2007
I am having problems getting the user selected form info to inserted into the mysql database.
I am also rec eving an error:
Warning: Variable passed to each() is not an array or object in
D:\web_server\webroot\common_list_process.php on line
1) I can display the contents of the $op array (see below)
2) Am I using the correct loop to unpact the array for inserting into the
database?
3) I have attempeted to correct the error: "Variable passed to each()
is not an array or object".
I don't understand why it is happening.
4) I am willing to consider another approach to accomplishing this.


<html>
<head></head>
<body>
<!-----------------------form processor---------------------------->
<form  action="../common_list_process.php"  method="post">
<table>
<tr>
  <td>         <input type="submit" name="fee_button" value="Submit"
             style="color: #ff6600;font-weight:bold; margin-right: 5;"/> </td>
</tr>
</table>
<?php
 display();//display form selection and input boxes 
?>
 
</form>
</body>
</html>
 
<?php
  
  /***------------display function------------**/
  //display form selection and input boxes
  
  function display()
  {
   $op = array();//create empty array
 
  /****This form consist of multiple rows  like this****/
   echo "<table>\n";
   echo "<tr height=\"10\">\n";
   echo "<td width=\"9%\" bgcolor=\"#fff8dc\" align=\"\"><span class=\"style15\">
          <input type=\"checkbox\" name=\"op[choice][]\" value=\"A1\">
           <span class=\"style1\" >A1</span></span></td>
  <td width=\"2%\" bgcolor=\"#fff8dc\" height=\"10\">
    <input type=\"text\" name=\"op[unit][]\" size=\"1\" maxlength=\"2\" value =\"$a_unit\"/></td>
         <td width=\"32%\" bgcolor=\"#ebeae0\" class=\"style11\">General</td>\n";
         
  echo "<td width=\"9%\" bgcolor=\"#fff8dc\" align=\"\"><span class=\"style15\">
         <input type=\"checkbox\" name=\"op[choice][]\" value=\"A7\">
          <span class=\"style1\" >A7</span></span></td>
         <td width=\"2%\" bgcolor=\"#ebeae0\" height=\"10\">
          <input type=\"text\" name=\"op[unit][]\" size=\"1\" maxlength=\"2\" value =\"$a_unit\"/></td>
         <td width=\"32%\" bgcolor=\"#ebeae0\" class=\"style11\">Intermediate</td>\n";
  echo "</tr>\n";
  echo "</table>\n";
  
  return $op; 
  }
?>
 
 

<?php
  /**---------common_list_process.php-----------**/
 
  echo '<pre>',print_r ($_POST, TRUE), '</pre>';//check array values
 
  //filter array
  if(is_array($_POST['wohip']))
     {
     $fee_code = array_filter($_POST['wohip']);
 
 }
 else
    {
  $fee_code = array($_POST['wohip']);
  $fee_code = array_filter($_POST['wohip']);
           }
  
  //loop to insert values into database
  for($row = 0; $row < 3; $row++)
   {
           while(list($choice, $unit, $fee_money) = each($fee_code[$row]))
             {
       $choice; $unit";
             }
          /**** insert code goes here *****/
 }
?>
 


/** -------------------results of page submission--------------------***/
[op] => Array
(
[unit] => Array
(
[0] =>
[1] =>
[2] => 3
[3] =>

[145] =>
[146] =>
)

[choice] => Array
(
[0] => A8
)
)
Warning: Variable passed to each() is not an array or object in D:\web_server\webroot\common_list_process.php on line
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 4:55 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC