PHP Non-serialize offset error

I have this code:

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

What prints this:

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

Then I add this code:

 echo unserialize($serialized); 

And end up with this error:

Note: unserialize () [function.unserialize]: error when shifting 5 out of 43 bytes in /mypage.php on line 5

What am I doing wrong with unserialize?

+4
source share
1 answer

It looks like you have included magic quotes . Either disable them, or run your value through stripslashes

 $serialized = stripslashes($_POST['cartSer']); 
+6
source

Source: https://habr.com/ru/post/1315014/


All Articles