[PHP] Registering an Array in a Session
Hi, I am trying to register an array in a session, but am having no luck. What I have is a form with set fields on which is processed a certain number of times. Upon submitting the form each time, I run the following: session_register(fieldtext[.$page.]); where fieldtext is the name of a field on the form, and $page is the page number, which increases by one each time the form is submitted. All I get registered is the last value submitted on the form, all the previous values are null. Any advice would be most appreciated. TIA Alexis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Registering an Array in a Session
I am trying to register an array in a session, but am having no luck. [..] where fieldtext is the name of a field on the form, and $page is the page number, which increases by one each time the form is submitted. ? php // Register the Session Variable, and increment this page session_register(fieldtext); $_SESSION[fieldtext][.$page.]++; // Show all pages print_r($_SESSION[fieldtext]); ? That should get you started. -- Dan Hardiker [[EMAIL PROTECTED]] ADAM Software Systems Engineer First Creative Ltd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] registering an array to a session?
Hi all! Is it possible to register an array to a session with PHP 4? If yes, how can it be done? Cheers, Kiko -- It's not a bug, it's a feature. christoph starkmann mailto:[EMAIL PROTECTED] http://www.gruppe-69.com/ ICQ: 100601600 -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] registering an array to a session?
You just register it...: $_SESSION['your_array'] = $your_array; It will be serialized automatically before stored. All the best, Eivind - Original Message - From: Christoph Starkmann [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, April 24, 2002 2:46 PM Subject: [PHP] registering an array to a session? Hi all! Is it possible to register an array to a session with PHP 4? If yes, how can it be done? Cheers, Kiko -- It's not a bug, it's a feature. christoph starkmann mailto:[EMAIL PROTECTED] http://www.gruppe-69.com/ ICQ: 100601600 -- -- 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] registering an array to a session?
Yes, just assign it as if you would do with a string or integer. Sincerely, Maxim Maletsky Founder, Chief Developer www.PHPBeginner.com // where PHP Begins -Original Message- From: Christoph Starkmann [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 24, 2002 2:46 PM To: '[EMAIL PROTECTED]' Subject: [PHP] registering an array to a session? Hi all! Is it possible to register an array to a session with PHP 4? If yes, how can it be done? Cheers, Kiko -- It's not a bug, it's a feature. christoph starkmann mailto:[EMAIL PROTECTED] http://www.gruppe-69.com/ ICQ: 100601600 -- -- 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] registering an array into a session (?)
No idea if this will help, but not sure why you are serializing the array... // sessionarray.php4 session_cache_limiter(""); session_start(); session_register('name'); session_register('city'); session_register('state'); session_register('postcode'); session_register('pagecount'); if (pagecount != "") { $name[] = $newName; $city[] = $newCity; $state[] = $newState; $postcode[] = $newPostcode; } ? html head /head body form method="post" action="? echo $PHP_SELF; ?" Enter a name: input type="text" name="newName"br Enter a city: input type="text" name="newCity"br Enter a state: input type="text" name="newState"br Enter a postcode: input type="text" name="newPostcode"br input type="submit" name="submit" value="enter values" /formbr br ? for ($i = 0; $i count($name); $i++) { echo "B $name[$i] /b $city[$i] $state[$i] $postcode[$i] br"; } $pagecount++; ? /body /html "Christian Dechery" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Can somebody please help me out?? I'm going nuts... what's wrong with this piece of code? pre if(!isset($script_total_time)) { // register the session variables to keep track of step times $script_total_time=(float)$total_time; session_register("script_total_time"); $step_times_array[$step]=$total_time; $step_times=serialize($step_times_array); //echo "step_times=\"$step_times\""; - this echoes perfeclty session_register("step_times"); } else { // update session variables $script_total_time+=(float)$total_time; $step_times_array=unserialize($step_times); $step_times_array[$step]=$total_time; $step_times=serialize($step_times_array); } /pre why doesn't $step_times gets registered correctly? it always register an empty var... . Christian Dechery (lemming) . http://www.tanamesa.com.br . Gaita-L Owner / Web Developer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] registering an array into a session (?)
Can somebody please help me out?? I'm going nuts... what's wrong with this piece of code? pre if(!isset($script_total_time)) { // register the session variables to keep track of step times $script_total_time=(float)$total_time; session_register("script_total_time"); $step_times_array[$step]=$total_time; $step_times=serialize($step_times_array); //echo "step_times=\"$step_times\""; - this echoes perfeclty session_register("step_times"); } else { // update session variables $script_total_time+=(float)$total_time; $step_times_array=unserialize($step_times); $step_times_array[$step]=$total_time; $step_times=serialize($step_times_array); } /pre why doesn't $step_times gets registered correctly? it always register an empty var... . Christian Dechery (lemming) . http://www.tanamesa.com.br . Gaita-L Owner / Web Developer