2012-02-01 91 views
2

有人能告诉我为什么这个字符串不会反序列化吗?我已经试过的一切(的stripslashes,和addslashes,修剪,等等...)不能反序列化字符串

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";} 

我得到“错误的偏移量370 952个字节”,但这并没有什么意义,“米“在Stream中是第370个字节。

谢谢!

+0

请将您的帖子中的代码显示为实际代码,而不是纯文本。序列化数据的未格式化的怪异性使我甚至不愿意试图回答你的问题。 – rdlowrey 2012-02-01 19:07:55

+1

@rdlowrey他的问题是关于反序列化不良数据......这不是关于代码。如果你不能看到数据,你怎么修复一个有关格式不正确的序列化数据的错误... – 2012-02-01 19:10:17

+0

[PHP Unserialize Offset Error]的可能重复(http://stackoverflow.com/questions/3199491/php-unserialize-偏移错误) - 您的序列化字符串已损坏。 – hakre 2012-02-01 19:13:27

回答

3

在位置324处不应该存在斜杠。在PHP中序列化数据使用字符计数。例如:

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

表示将会有一串49个字符出现在下面的引号中。但是如果你计算正确的话,在这个字符串中有一个“50”字符。如果你试图逃避它,请不要通过它来解决你的问题。

在位置844修复这个问题后,似乎还有另一个错误,即product_url的结尾,它似乎缺少一个字符,可能是url中的尾部斜杠,因为url长度为45个字符,但它是期待一个46字符长的网址...

所以可以矫正你的串行数据后,我得到这个:

一:10:{S:8: “ORDER_ID”; S:13: “9006710350464” S:5: “买方”; S:10: “1303912674”; S:3: “应用程序”,S:15: “223615011031939”; S:8: “接收器”; S:10: “1303912674”; S: 6: “量”; S:2: “20”; S:11: “time_placed”; S:10: “1326235812”; S:11: “UPDATE_TIME”; S:10: “1326235818”; S:4: “数据”; S:0: “”,S:5 : “项目”;一个:1:{I:0;一个:7:{S:7: “ITEM_ID”; S:4: “1_48”; S:5: “标题”,S:49:“我电影中的耶稣妈妈一段时间没有耶稣妈妈(全电影) - 48小时 流的“; s:11:”描述“; s:204:”这是一个看我不是 48小时。 完成购买后,您的帐户将可以观看 电影,最长可播放48小时。“; s:9:”image_url“; s:144:”https://filmdemic.com/apps/fb -streaming/WP-主/可湿性粉剂内容/主题/ FD-FB-流WPF的孩子/库/图像/标题/ slidersize/im_not_jesus_mommy.jpg “; S:11:” product_url “; S:46:” HTTP ://filmdemic.com/apps/fb-streaming/film-1/ “; S:5:” 价格 “S:2:” 20 “; S:4:” 数据 “; S:37:” film_id = 1 & wp_user_id = 4 & view_length = 48 “;}} S:6:” 状态 “; S:6:” 放置“;}

并且它导致成

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', 
) 
+0

就是这样。你钉在头上。我用查找更新了sql数据库并替换了产品url来改变它们,不知道序列化格式如何工作,从而产生了字符串长度的差异。谢谢! – chuuke 2012-02-01 19:24:07

+0

非常感谢你的想法! unserialize之前的反锯齿帮助。 – Panoptik 2015-03-27 13:54:28

+0

我很惊讶地发现一个逃逸的角色可能会炸毁序列化/反序列化的明显伪对称特性。我们是2016年,反序列化从2000年推出的PHP4开始(!)此外,沉默失败只是一个/ var_dump地狱的秘诀,我只是通过调试某人的方式发现了困难的方式。 – 2016-07-11 04:51:13