chuuke
chuuke

Reputation: 606

Cannot Unserialize String

Can someone tell me why this string won't unserialize? I've tried just about everything (stripslashes, addslashes, trim, etc etc...)

a:10:{s:8:"order_id";s:13:"9006710350464";s:5:"buyer";s:10:"1303912674";s:3:"app";s:15:"223615011031939";s:8:"receiver";s:10:"1303912674";s:6:"amount";s:2:"20";s:11:"time_placed";s:10:"1326235812";s:11:"update_time";s:10:"1326235818";s:4:"data";s:0:"";s:5:"items";a:1:{i:0;a:7:{s:7:"item_id";s:4:"1_48";s:5:"title";s:49:"I\'m Not Jesus Mommy (Full Movie) - 48 Hour Stream";s:11:"description";s:204:"This is a purcahse to watch I\'m Not Jesus Mommy on FilmDemic Movie Streaming for a period of 48 hours. Once you complete the purchase, your account will have access to watch the movie for up to 48 hours.";s:9:"image_url";s:144:"https://filmdemic.com/apps/fb-streaming/wp-main/wp-content/themes/fd-fb-stream-wpf-child/library/images/titles/slidersize/im_not_jesus_mommy.jpg";s:11:"product_url";s:46:"http://filmdemic.com/apps/fb-streaming/film-1";s:5:"price";s:2:"20";s:4:"data";s:37:"film_id=1&wp_user_id=4&view_length=48";}}s:6:"status";s:6:"placed";}

I get "Error at offset 370 of 952 bytes", but that doesn't make sense, the "m" in Stream is the 370th byte.

Thanks!

Upvotes: 2

Views: 2688

Answers (1)

Mathieu Dumoulin
Mathieu Dumoulin

Reputation: 12244

There is a slash that shouldn't be there at position 324. Serializing data in PHP uses character counting. For example:

s:49:"I\'m Not Jesus Mommy (Full Movie) - 48 Hour Stream"

Says that there will be a string of 49 characters coming in the following quotes. But if you calculate correctly, there is a \ in this string that makes the count 50 character. If you tried to escape it, please unescape it to fix your issue.

There seems to be also another error after fixing this at position 844 which is the end of your product_url, it seems to be missing one character, probably a trailing slash in the url because the url is 45 characters long but it is expecting a 46 character long url...

So after correcting your serialized data i get this:

a:10:{s:8:"order_id";s:13:"9006710350464";s:5:"buyer";s:10:"1303912674";s:3:"app";s:15:"223615011031939";s:8:"receiver";s:10:"1303912674";s:6:"amount";s:2:"20";s:11:"time_placed";s:10:"1326235812";s:11:"update_time";s:10:"1326235818";s:4:"data";s:0:"";s:5:"items";a:1:{i:0;a:7:{s:7:"item_id";s:4:"1_48";s:5:"title";s:49:"I'm Not Jesus Mommy (Full Movie) - 48 Hour Stream";s:11:"description";s:204:"This is a purcahse to watch I\'m Not Jesus Mommy on FilmDemic Movie Streaming for a period of 48 hours. Once you complete the purchase, your account will have access to watch the movie for up to 48 hours.";s:9:"image_url";s:144:"https://filmdemic.com/apps/fb-streaming/wp-main/wp-content/themes/fd-fb-stream-wpf-child/library/images/titles/slidersize/im_not_jesus_mommy.jpg";s:11:"product_url";s:46:"http://filmdemic.com/apps/fb-streaming/film-1/";s:5:"price";s:2:"20";s:4:"data";s:37:"film_id=1&wp_user_id=4&view_length=48";}}s:6:"status";s:6:"placed";}

And it results into

array (
  'order_id' => '9006710350464',
  'buyer' => '1303912674',
  'app' => '223615011031939',
  'receiver' => '1303912674',
  'amount' => '20',
  'time_placed' => '1326235812',
  'update_time' => '1326235818',
  'data' => '',
  'items' => 
  array (
    0 => 
    array (
      'item_id' => '1_48',
      'title' => 'I'm Not Jesus Mommy (Full Movie) - 48 Hour Stream',
      'description' => 'This is a purcahse to watch I\'m Not Jesus Mommy on FilmDemic Movie Streaming for a period of 48 hours. Once you complete the purchase, your account will have access to watch the movie for up to 48 hours.',
      'image_url' => 'https://filmdemic.com/apps/fb-streaming/wp-main/wp-content/themes/fd-fb-stream-wpf-child/library/images/titles/slidersize/im_not_jesus_mommy.jpg',
      'product_url' => 'http://filmdemic.com/apps/fb-streaming/film-1/',
      'price' => '20',
      'data' => 'film_id=1&wp_user_id=4&view_length=48',
    ),
  ),
  'status' => 'placed',
)

Upvotes: 3

Related Questions