Thanks. 
var_dump ($_REQUEST) displayed the word 'Array'.

I think there is a basic problem with passing array
variables via forms. Look have even tried a simple to
pass a small array variable just to test the
principle, test like this one:-


# p1.php 
<?
$row = array
(
        "BOOK1" => "PHP",
        "BOOK2" => "JAVA",
);
?>
<html><body>
<form method='POST' action='p2.php'>
<input type='hidden' name='row' value=$row>
<input type='submit' value='Submit' name='submit'>
</form>
</body></html>


#p2.php

<?
$row = $_POST['row'];
foreach ($row as $BOOK => $VALUE)
{
echo $BOOK . ':' . $VALUE;
}
?>

and Im still getting the Warning: invalid arguement
etc..

also:
echo $row;  // produced 'Array'

echo $row[0]; // produced 'A'
echo $row [1]; // produced 'r'

and so on..

It baffles me really .. this is now elementary PHP not
working as expected!!!

-- Jeromie Clark <[EMAIL PROTECTED]> wrote:

> The other issue might be the spaces between the
> parameter and the "="s 
> in your <input> lines.
> I'm not sure if the browser is going ignore what's
> going on there or not.
> 
> You can dump the contents of the $_REQUEST variable
> to see what's 
> actually getting sent to the script.
> 
> example:
> var_dump($_REQUEST);
> 
> That should give you some idea of what's going on.
> If the $_REQUEST array is empty, then I'd reformat
> that HTML like this:
> 
> <form action='filename'>
> <input type='hidden' name='rows' value='$row'>
> <input type='button' name='submit' type='submit'>
> </form>
> 
> -Jeromie
> 
> ><form action =
> >'display_as_comma_separated_fields.php'>
> ><input type = 'hidden' name = 'rows' value =
> '$row'>
> ><input type = 'button' name = 'submit' type =
> >'submit'>
> ></form>
> >
> >Note the value of the hidden field i.e. $row.  This
> >$row is the array already retrieved from the
> database
> >table.
> >
> >Then, I thought, I could post it to the other php
> page
> >and process it again, using "foreach". In theory
> this
> >seemed perfectly okay but when I do it like this:-
> >
> >#on  page: 'display_as_comma_separated_fields.php'
> #
> >
> >$rows = $_POST['rows']; // the array passed in the
> >hidden field
> >
> >if ($submit)
> >{
> >
> >   foreach ($rows as $value)
> >   {
> >    echo $value[0] . ',' $value[1] . ','$value[2] .
> >'<br>';
> >   }
> >}
> >
> >
> >For some reason, I get the error:
> >Warning: Invalid argument supplied for foreach()..
> >
> >.. and for the life of me I cant see why !!!
> >
> >Any suggestion? Many thanks
> >
> >--- Jeromie Clark <[EMAIL PROTECTED]> wrote:
> >
> >
> >---------------------------------
> >It's hard without some context, but I'm guessing
> that
> >you should be 
> >looking for your post results in the global $_POST
> >variable, but you're not.
> >
> >Example:
> >
> >You've got a form, with an element called "item":
> ><form method='POST' action='target_url.php'>
> ><input type='text' name='item'>
> ><input type='submit' value='Go &gt;&gt;'>
> >
> >On your target page, the value from the form is
> going
> >to be in the 
> >$_POST array.
> >
> >example:
> >echo $_POST['item'];
> >
> >Also, if you need to post an array of data via a
> form,
> >you can have 
> >multiple elements with the same name.
> >This is commonly used for checkboxes, where you can
> >have multiple 
> >specified values for one field:
> >
> ><form method='POST' action='target_url.php'>
> ><input type='checkbox' name='colors[]' value='red'>
> ><input type='checkbox' name='colors[]'
> value='blue'>
> ><input type='checkbox' name='colors[]'
> value='green'>
> ></form>
> >
> >The '[]' at the end of the name tells PHP to
> compile
> >all the values into 
> >an array for you.
> >
> >Then, you could do:
> >
> >foreach($_POST['colors'] AS $color) {
> >    echo $color . ",";
> >}
> >
> >Hope that helps,
> >Jeromie
> >
> >  
> >
> >>Hello
> >>I have this problem that seems at the surface dead
> >>easy .., yet ive been struggling with it for a
> couple
> >>of days
> >>
> >>Id like to give users the option of saving
> selected
> >>data by clicking on a button. When this is done,
> the
> >>same rows would be displayed but this time with
> >>comma-separated values, and nothing else. No
> graphics
> >>or other options/buttons on the screen. Then a
> user
> >>would simply save the page as text or html.
> >>
> >>What I have been trying to do without success, is
> to
> >>post the array in a hidden field to another page. 
> >>    
> >>
> >And
> >  
> >
> >>then try :
> >>foreach ($array as $value){
> >>
> >>etc..}
> >>
> >>But for some reason that has not worked for me.  I
> >>keep gettin the error :
> >>Warning: Invalid argument supplied for foreach()
> ..
> >>
> >>Your suggestions are greatly appreciated,
> >>
> >>David
> >>



                
___________________________________________________________ 
Win a BlackBerry device from O2 with Yahoo!. Enter now. 
http://www.yahoo.co.uk/blackberry


The php_mysql group is dedicated to learn more about the PHP/MySQL web database 
possibilities through group learning.  
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php_mysql/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to