Jump to content


Photo

Can't pass an array variable between pages


  • Please log in to reply
23 replies to this topic

#21 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 16 March 2006 - 05:57 PM

[!--quoteo(post=355591:date=Mar 16 2006, 06:19 PM:name=gmd06)--][div class=\'quotetop\']QUOTE(gmd06 @ Mar 16 2006, 06:19 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
When i put in the print_r i get:

Array
(
       [ints] => a:10:{i:0;s:2:
       [submit] => Pass it
)

The Error at offset is still there too. I added the stripslashes and it stayed the same.
[/quote]
Change line
<input type="hidden" name="ints" value="<?=$passedValue1?>"/>
in form to
<input type="hidden" name="ints" value='<?=$passedValue1?>'/>
" -> '
and
$ints = unserialize($_POST['ints']);
to
$ints = unserialize(stripslashes($_POST['ints']));


#22 gerrydewar

gerrydewar
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 16 March 2006 - 06:16 PM

Ken tried what you said but it was still the same. offset error was still there

Sasa, i tried what you said and the offset error has gone but i only get:

Array
(
     [Ints] =>
     [submit] =>
)
There is still no array info.

Ken, meant to say that when i put in

<?php echo '<pre>' .  $passedValue1 . '</pre>'; ?>

i get

a:10:{i:0;s:1:"1";i:1;s:2:"17";i:2;s:1:"3";i:3;s:1:"4";i:4;s:2:"13";i:5;s:1:"2";i:6;s:1:"5";i:7;s:1:"9";i:8;
s:2:"11";i:9;s:2:"10";}

across the screen.

#23 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 16 March 2006 - 06:59 PM

You'll notice that there are double quotes in the serialized string.

Use the following line for the <input>:
<input type="hidden" name="ints" value="<?php echo htmlentities($passedValue1)?>"/>
and leave the stripslashes() on the unserialize line.

Ken

#24 gerrydewar

gerrydewar
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 16 March 2006 - 07:09 PM

Guess what? It worked. I now have my array elements on screen. Thankyou to everyone that contributed, particularly Ken. I'm sure to have some more questions in the coming weeks. hopefully not as demanding as this one. Thankyou.

I'll buy you all a cyber drink




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users