2012-02-01 2 views
0

다음 코드의 문제점은 무엇입니까? 이 문자열을 일렬 화를 푸는 때 나는 부울 거짓을 얻고있다 : I 데이터 직렬화하기 위해 다음 코드를 사용하고PHP에서 문자열을 비 직렬화 할 수 없습니다.

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

:

$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'))"; 

을 그리고 다음과 같은 코드가 문자열을 비 일렬 화 할 수 있습니다.

$sql = "select uncompress(RepData) as RData from table"; 
$rData = unserialize(html_entity_decode($data['RData'])); 
+1

비 직렬화 코드는 무엇입니까? – JJJ

답변

0

난 그냥 serialize()unserialize() 사용 기대합니다.

내가 실행할 때 Error at offset 169 of 700 bytes을받습니다. 특수 문자를 인코딩하고 따옴표를 이스케이프 처리해야합니다. 방법은 다음과 같습니다 ->http://davidsword.ca/unserialize-error-at-offset/

+0

그냥 htmlentities 및 html_entity_decode 함수를 사용하는 대신 문제를 해결, addslashes 및 stripslashes 함수를 사용합니다. – appsdevpk

관련 문제