Connecting Tech Pros Worldwide Forums | Help | Site Map

unserialize() isn't working....

Sebastian Aguilera
Guest
 
Posts: n/a
#1: Jul 17 '05
Hi everyone.
I have some troubles using the unserialize() function.

I have serialized an array and that works perfect:

echo '<input type="hidden" name="vardekedja" value="'.serialize($_POST
['vardekedja']).'">';

Gives the output:
a:3:{i:0;s:7:

Then on a later page I write:
$vardekedja = $_POST['vardekedja'];
$varde = unserialize($vardekedja);
echo $vardekedja; echo '
';
echo $varde; echo '
';
echo 'why?';

And, as I echoed out, WHY?

why isn't it working??

Please help!
/Sebastian


Pedro Graca
Guest
 
Posts: n/a
#2: Jul 17 '05

re: unserialize() isn't working....


Sebastian Aguilera wrote:[color=blue]
> Hi everyone.
> I have some troubles using the unserialize() function.
>
> I have serialized an array and that works perfect:
>
> echo '<input type="hidden" name="vardekedja" value="'.serialize($_POST
> ['vardekedja']).'">';
>
> Gives the output:
> a:3:{i:0;s:7:
>
> Then on a later page I write:
> $vardekedja = $_POST['vardekedja'];
> $varde = unserialize($vardekedja);
> echo $vardekedja; echo '
> ';
> echo $varde; echo '
> ';
> echo 'why?';
>
> And, as I echoed out, WHY?
>
> why isn't it working??[/color]

Have you tried "View Source"?

serialize() uses double quotes (") and these quotes don't mix well with
the HTML quotes!


try htmlentities()

echo '<input type="hidden" name="vardekedja" value="'
. htmlentities(serialize($_POST['vardekedja']))
. '">';



But why are you serializing the $_POST array to put _into_ the form?
Well ... try it :-)
--
--= my mail address only accepts =--
--= Content-Type: text/plain =--
--= Size below 10K =--
Closed Thread