Re: [PHP] Passing array variables in a GET

2003-10-22 Thread Jason Wong
On Thursday 23 October 2003 02:41, Jeff McKeon wrote:

> I looked at the page you suggested but it vauge at best.  Basically from
> what I've gathered using serialize with an array screws up the pointers
> in the array.  Is this true?

If you mean the internal pointer, ie the one that is reset by calling reset(), 
then who cares. Keeping that pointer across pages has little/no value. What 
is important is that the structure and values of the array is intact.

> What I've done is this but it doesn't seem to be working...
>
> Pull data (two fields) from a mysql table and put the results into two
> arrays, one for each field
>
> Query results for field 1 -> Array1[]
> Query results for field 2 -> Array2[]
>
> Then I create a variable with the imploded data from the arrays
>
> $var1=implode(":", $Array1);
> $var2=implode(":", $Array2);
>
> Then serialize the variables...
>
> $varSER1=serialize($var1);
> $varSER2=serialize($var2);

AFAICS serialize() on a string seems to be redundant. serialize() is supposed 
to represent some complex entity (eg an array) as a string so it can be 
easily stored, transmitted etc.

So something like:

  $var_to_pass_in_url = urlencode(serialize($Array1));

Then construct your url like so:

  http://www.example.com/example.php?Array1=$var_to_pass_in_url

Then in example.php you reconstruct the array:

  $Array1 = unserialize($_GET['Array1']);

ought to work (but untested).

> Then pass the variables in the url via a GET.
>
> It doesn't work however

*How* doesn't *What* work?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
The opposite of a correct statement is a false statement. But the opposite
of a profound truth may well be another profound truth.
-- Niels Bohr
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Passing array variables in a GET

2003-10-22 Thread Jeff McKeon
I looked at the page you suggested but it vauge at best.  Basically from
what I've gathered using serialize with an array screws up the pointers
in the array.  Is this true?

What I've done is this but it doesn't seem to be working...

Pull data (two fields) from a mysql table and put the results into two
arrays, one for each field

Query results for field 1 -> Array1[]
Query results for field 2 -> Array2[]

Then I create a variable with the imploded data from the arrays

$var1=implode(":", $Array1);
$var2=implode(":", $Array2);

Then serialize the variables...

$varSER1=serialize($var1);
$varSER2=serialize($var2);

Then pass the variables in the url via a GET.  

It doesn't work however

Jeff 

> -Original Message-
> From: Wouter van Vliet [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, October 22, 2003 1:06 PM
> To: Jeff McKeon; [EMAIL PROTECTED]
> Subject: RE: [PHP] Passing array variables in a GET
> 
> 
> Take a look at 
> http://nl.php.net/manual/en/function.serialize.php and 
> http://nl.php.net/manual/en/function.unseriali> ze.php. Or if 
> the keys don't matter and the array has just 
> one level (strange, I know there's a different term for that, 
> totally cannot find it in my memory :S) you can consider
> join() and split().
> 
> Wouter
> 
> -Original Message-
> From: Jeff McKeon [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday 22 October 2003 18:59
> To: [EMAIL PROTECTED]
> Subject: [PHP] Passing array variables in a GET
> 
> Is this possible???
> 
> $blah[]=(a, b, c);
> 
> link
> 
> So basically I have a page that need an array to perform some 
> function. Can I pass that array variable (and thus it's data) 
> to it from another page?
> 
> Thanks,
> 
> Jeff
> 
> --
> 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] Passing array variables in a GET

2003-10-22 Thread Wouter van Vliet
Take a look at http://nl.php.net/manual/en/function.serialize.php and
http://nl.php.net/manual/en/function.unserialize.php. Or if the keys don't
matter and the array has just one level (strange, I know there's a different
term for that, totally cannot find it in my memory :S) you can consider
join() and split().

Wouter

-Original Message-
From: Jeff McKeon [mailto:[EMAIL PROTECTED] 
Sent: Wednesday 22 October 2003 18:59
To: [EMAIL PROTECTED]
Subject: [PHP] Passing array variables in a GET

Is this possible???

$blah[]=(a, b, c);

link

So basically I have a page that need an array to perform some function.
Can I pass that array variable (and thus it's data) to it from another page?

Thanks,

Jeff

--
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