普通网友 2012-02-01 09:32 采纳率: 0%
浏览 47
已采纳

无法在php中反序列化字符串

Can any one tell me what is the problem with the following code? I am getting boolean false when unserializing this string:

a:3:{s:10:"Subscriber";O:14:"SubscriberType":8:{s:14:"organizationid";s:3:"omm";s:5:"jobid";s:13:"4f27d819d9fd2";s:8:"sequence";s:8:"42781971";s:20:"SubscriberTypedate";s:10:"2012-01-31";s:20:"SubscriberTypetime";s:8:"04:01:29";s:9:"timestamp";s:19:"2012-01-31T04:01:29";s:20:"SubscriberTypecert";s:46:"omm^4f27d819d9fd2^42781971^2012-01-31T04:01:29";s:11:"certificate";s:32:"ab673e29e0eb69a62b39781cdbec6368";}s:8:"Activity";O:12:"ActivityType":6:{s:5:"title";s:6:"ethics";s:8:"provider";s:21:"O'Melveny & Myers LLP";s:6:"format";s:2:"11";s:10:"completion";s:10:"2012-01-12";s:11:"description";s:35:"some's : test description here";s:7:"credits";s:17:"some credits here";}s:4:"Code";s:8:"SMH10634";}

I am using following code to serialize the data:

$stype = new SubscriberType($data1['OrgID'],$data1['OrgKey']);
$atype = new ActivityType($rdata['Title'],$data1['Provider'],$rdata['Format'],$rdata['Completion'],$rdata['Description'],$rdata['Credits']);
$repData = htmlentities(serialize(array("Subscriber"=>$stype,"Activity"=>$atype,"Code"=>$data2['ClientCode'])),ENT_QUOTES);
$sql = "insert into table values(compress('$repData'))";

And the following code to unserialize it.

$sql = "select uncompress(RepData) as RData from table";
$rData = unserialize(html_entity_decode($data['RData']));
  • 写回答

1条回答 默认 最新

  • douyu0845 2012-02-01 09:43
    关注

    I expect you just use serialize() and unserialize().

    When i run it I receive Error at offset 169 of 700 bytes. You should encode special charachters and escape quotes. Here is how -> http://davidsword.ca/unserialize-error-at-offset/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测