•
•
•
•
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
![]() |
•
•
Join Date: Oct 2006
Posts: 76
Reputation:
Rep Power: 2
Solved Threads: 0
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.
/** -------------------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
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
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Please helpwith how to return two dimensional array (C++)
- non-static and variable errors (Java)
- filling variable with array from vb code. (HTML and CSS)
- Array Problem (C++)
- how to set up my for loop to print my array in reverse (Java)
- $variable inside quotes (PHP)
- Array declaration problem (C++)
- automatic type conversion (PHP)
- Command Line Parameter (C++)
Other Threads in the PHP Forum
- Previous Thread: Coding a PvP Arena - Help
- Next Thread: Problem with forms


Linear Mode