views:

29

answers:

1

I have this code:

$serialized = $_POST['cartSer'];   
echo $serialized;

Which prints this:

a:1:{s:15:\"test\";s:3:\"999\";}

I then add this code:

echo unserialize($serialized); 

And end up with this error:

Notice: unserialize() [function.unserialize]: Error at offset 5 of 43 bytes in /mypage.php on line 5

What am I doing wrong with the unserialize?

+2  A: 

Sounds like you have magic quotes enabled. Either disable them, or run your value through stripslashes

$serialized = stripslashes($_POST['cartSer']);
Paul Dixon