Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Help > PHP Programming Help

PHP Programming Help Post any question relating to PHP Programming here and hopefully someone can help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2005-12-13, 12:54 PM
Junior Member
 
Join Date: Sep 2004
Posts: 8
clem_c_rock
Default

Hello,

I'm trying to serialize an array, then throw it into a url stream to pass it to a new page where I will then unserialize the array. When I pass it to the next page and do a print_r( $unserialized_array ), I get no values.

Here's the code I'm trying:

Page 1:

$array = array();
$array["a"] = "Foo";
$array["b"] = "Bar";
$array["c"] = "Baz";
$array["d"] = "Wom";

$test_array = serialize( $array );

Url string: <a href="page_2.php?serialized_array=<?=$test_array ?>" >


Page 2:

$this_code_array = array();
$this_code_array = unserialize( urldecode( $_REQUEST['serialized_array'] ) );
print_r( $this_code_array ); // will not print anything
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2005-12-13, 06:54 PM
Junior Member
 
Join Date: Sep 2004
Posts: 8
clem_c_rock
Default

Ok - I solved it nicely w/ this here bit of code;


PAGE 1:

$this_code_value_array = array();
$this_code_value_array = serialize( $this_code_value_array );

Url:

$url = "page_2.php?serialized_array=" . urlencode($test_array);

PAGE 2:

$unserialized_code_array = array();
$unserialized_code_array = unserialize( stripslashes( urldecode( $_REQUEST['code_array'] ) ) );
Reply With Quote
  #3 (permalink)  
Old 2005-12-13, 09:53 PM
Senior Member
 
Join Date: Dec 2004
Posts: 199
strasm is an unknown quantity at this point
Default

You can also do it with sessions. The main advantage to sessions is you can call them from any page without passing it each time, and the syntax is much easier.

Code:
session_start();

$_SESSION[user][name] = "bill jackson";
page 2
Code:
session_start();
$name = $_SESSION[user][name];
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:00 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.