2011-10-15 109 views
0

-反序列化偏移量錯誤

我有一個序列化數組發送到我的應用程序中的另一個函數。 然後我嘗試反序列化數據並將其呈現在另一個地方。

反序列化函數對較小的ammout數據(如幾百條記錄)有效。當涉及到3000+記錄我已經得到了以下錯誤消息:

Notice (8): unserialize() [function.unserialize]: Error at offset 23048 of 3499833 bytes [APP/controllers/jobs_controller.php, line 475] 

Warning (2): Cannot modify header information - headers already sent by (output started at /home/v/s/vsdev/web/public_html/cake/libs/debugger.php:683) [APP/views/helpers/xls.php, line 19] 

Warning (2): Cannot modify header information - headers already sent by (output started at /home/v/s/vsdev/web/public_html/cake/libs/debugger.php:683) [APP/views/helpers/xls.php, line 20] 

Warning (2): Cannot modify header information - headers already sent by (output started at /home/v/s/vsdev/web/public_html/cake/libs/debugger.php:683) [APP/views/helpers/xls.php, line 21] 

Warning (2): Cannot modify header information - headers already sent by (output started at /home/v/s/vsdev/web/public_html/cake/libs/debugger.php:683) [APP/views/helpers/xls.php, line 22] 

Warning (2): Cannot modify header information - headers already sent by (output started at /home/v/s/vsdev/web/public_html/cake/libs/debugger.php:683) [APP/views/helpers/xls.php, line 23] 

Warning (2): Cannot modify header information - headers already sent by (output started at /home/v/s/vsdev/web/public_html/cake/libs/debugger.php:683) [APP/views/helpers/xls.php, line 24] 

Warning (2): Cannot modify header information - headers already sent by (output started at /home/v/s/vsdev/web/public_html/cake/libs/debugger.php:683) [APP/views/helpers/xls.php, line 25] 

Link Job Job Ref Company Link Profession Specialism Sub Specialism Zone Country Region City Seniority Date Published Date Archived Days Active Email Enabled Created Modified 

Warning (2): Invalid argument supplied for foreach() [APP/views/jobs/search_export.ctp, line 37] 

有什麼不對?

+1

您需要檢查偏移量爲23048(1偏移量= 1個字符)的反序列化/原始字符串並從那裏開始。 ''serialize()'not'unserialize()'有問題(或之前)' –

+0

請參閱:http://stackoverflow.com/a/10152996/1226894 – Baba

回答

1

引發錯誤的記錄中的數據幾乎肯定會損壞。這應該與您請求的記錄數量無關,只是一個或多個具有無效序列化數據的特定記錄。嘗試找出錯誤中的哪些記錄結果,並檢查其數據。

在旁註:您使用什麼列類型來存儲序列化數據?我發現在MySQL中使用TEXT時,序列化數據可能會被MySQL對文本執行的操作不可逆轉地破壞,從而導致反序列化()錯誤。將BLOB用於序列化數據列,這樣數據保持不變。

+0

我不存儲序列化的數據。我只序列化它,以便我可以發送它並在另一個函數中重新打開它。 –

+0

如果你不存儲數據,你爲什麼要序列化數據? –

+0

我有一個搜索。它是一個查詢,這個查詢的結果是一個數組。爲了顯示結果,我有一個循環遍歷數組。在底部有一個按鈕「導出結果」。該功能使我可以導出結果。爲此,我需要序列化結果,以便將其作爲隱藏值發送,然後在.xls視圖中將其反序列化。 –