Re: [PHP] sending array
This method seems to have a size limitation (which is very small). If your array is (relatively) large, page two will not display the passed values. I'm not sure the url string became too long or if the problem came from SERIALIZE(). Just beware. FYI -john =P e p i e D e s i g n s www.pepiedesigns.com Providing Solutions That Increase Productivity Web Developement. Database. Hosting. Multimedia. On Wed, 15 Jan 2003, Danielle van Gladbach wrote: > It works thanks > > Here is the code, if anyone has the same problem: > test1.php > $org["index-A"]=1701; > $org["index-B"]=1209; > > $var=serialize($org); > $var=urlencode($var); > > print "test2\n"; > ?> > > test2.php > $var=urldecode($var); > $org=unserialize($var); > > while (list ($key, $val) = each($org)) > { > print "key=".$key."val".$val."\n"; > } > ?> > > Jason Wong wrote: > > > On Wednesday 15 January 2003 20:59, Danielle van Gladbach wrote: > > > > > I am trying to send an array from one php to another: > > > > > > $org["index-A"]=1701; > > > $org["index-B"]=1209; > > > > > > print "test2\n"; > > > > > > But if I try to read te array in test2.php, I get "Warning: Variable > > > passed to each() is not an array ". > > > > You can't pass an array thru the URL. What you need to do is serialize() it > > then urlencode() it (or maybe rawurlencode()). Then you can put the resulting > > string in the URL. > > > > In test2.php you would unserialize() $org ($_GET['org']). > > > > -- > > Jason Wong -> Gremlins Associates -> www.gremlins.biz > > Open Source Software Systems Integrators > > * Web Design & Hosting * Internet & Intranet Applications Development * > > > > /* > > E Pluribus Unix > > */ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending array
On Thursday 16 January 2003 23:59, Gerald Timothy Quimpo wrote: > e.g., you might have a system whereby you encode the array > somehow into something easily parsed, e.g., index->value > pairs separated by a special delimiter, or urlencoded index > and value separated by a space. save the encoded format > on the disk. give it a random name. then pass the name to > the other URL as a GET param. > > you would also have a reaper program (maybe running through > crontab if you're on Unix, or some windows scheduler otherwise) > that deletes array files that are more than, say, 5 minutes old. IOW use sessions :-) -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* The two oldest professions in the world have been ruined by amateurs. -- G.B. Shaw */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending array
On Wednesday 15 January 2003 08:59 pm, Danielle van Gladbach wrote: > I am trying to send an array from one php to another: > > $org["index-A"]=1701; > $org["index-B"]=1209; > > print "test2\n"; > > But if I try to read te array in test2.php, I get "Warning: Variable > passed to each() is not an array ". others have discussed the particular error and things to try, so i won't do that here. instead i point out that if the array is going to be any significant length, then you might want to use some method of sending the array other than sending it in the URI. the particular limits on URI length are browser and web server (and sometimes OS dependent), but i'd be conservative about sending arrays along. i'd probably completely give up on sending them in the URI and instead construct some other way. e.g., you might have a system whereby you encode the array somehow into something easily parsed, e.g., index->value pairs separated by a special delimiter, or urlencoded index and value separated by a space. save the encoded format on the disk. give it a random name. then pass the name to the other URL as a GET param. you would also have a reaper program (maybe running through crontab if you're on Unix, or some windows scheduler otherwise) that deletes array files that are more than, say, 5 minutes old. tiger -- Gerald Timothy Quimpo tiger*quimpo*org gquimpo*sni-inc.com tiger*sni*ph Public Key: "gpg --keyserver pgp.mit.edu --recv-keys 672F4C78" Veritas liberabit vos. Doveryai no proveryai. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending array
It works thanks Here is the code, if anyone has the same problem: test1.php test2\n"; ?> test2.php \n"; } ?> Jason Wong wrote: > On Wednesday 15 January 2003 20:59, Danielle van Gladbach wrote: > > > I am trying to send an array from one php to another: > > > > $org["index-A"]=1701; > > $org["index-B"]=1209; > > > > print "test2\n"; > > > > But if I try to read te array in test2.php, I get "Warning: Variable > > passed to each() is not an array ". > > You can't pass an array thru the URL. What you need to do is serialize() it > then urlencode() it (or maybe rawurlencode()). Then you can put the resulting > string in the URL. > > In test2.php you would unserialize() $org ($_GET['org']). > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > > /* > E Pluribus Unix > */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sending array
You know, if you actually looked at the link you've created you'd find your answer ... > -Original Message- > From: D.M. van Gladbach [mailto:[EMAIL PROTECTED]] > > There not much in there because I strip it for testing. > > test1.php > $org["index-A"]=1701; > $org["index-B"]=1209; > > print "test2\n"; > ?> > > test2.php > while (list ($key, $val) = each($org)) > { > print "key=".$key."val".$val."\n"; > } > ?> > >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending array
There not much in there because I strip it for testing. test1.php test2\n"; ?> test2.php \n"; } ?> Rick Emery wrote: > show us the test1.php code. > show us the test2.php code. > We can't read your mind. > - Original Message - > From: "Danielle van Gladbach" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, January 15, 2003 6:59 AM > Subject: [PHP] sending array > > Hi, > > I am trying to send an array from one php to another: > > $org["index-A"]=1701; > $org["index-B"]=1209; > > print "test2\n"; > > But if I try to read te array in test2.php, I get "Warning: Variable > passed to each() is not an array ". > > Can anyone help me > Danielle > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending array
On Wednesday 15 January 2003 20:59, Danielle van Gladbach wrote: > I am trying to send an array from one php to another: > > $org["index-A"]=1701; > $org["index-B"]=1209; > > print "test2\n"; > > But if I try to read te array in test2.php, I get "Warning: Variable > passed to each() is not an array ". You can't pass an array thru the URL. What you need to do is serialize() it then urlencode() it (or maybe rawurlencode()). Then you can put the resulting string in the URL. In test2.php you would unserialize() $org ($_GET['org']). -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* E Pluribus Unix */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending array
show us the test1.php code. show us the test2.php code. We can't read your mind. - Original Message - From: "Danielle van Gladbach" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, January 15, 2003 6:59 AM Subject: [PHP] sending array Hi, I am trying to send an array from one php to another: $org["index-A"]=1701; $org["index-B"]=1209; print "test2\n"; But if I try to read te array in test2.php, I get "Warning: Variable passed to each() is not an array ". Can anyone help me Danielle -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php