duanmei4149 2016-05-12 13:07
浏览 156
已采纳

注意:unserialize():偏移0处的错误为5472字节ERROR

I get this error: Notice: unserialize(): Error at offset 0 of 5472 bytes in /home3/trisoni2/public_html/ohappy/admin/model/extension/module.php on line 32

I don't know what could be the reason. In PHP I do not really understand, so I give piece of code with a 32 string

if ($query->row) {
        if( $query->row['code'] == 'dimastas' ){  
            return $setting =  unserialize($query->row['setting']); /*<--- 32 string*/
        }
        return json_decode($query->row['setting'], true);
    } else {
        return array(); 
    }
}

Initially the entries in the database look like this:

a:5:{s:6:"status";s:1:"1";s:4:"name";s:7:"Default";s:5:"class";s:0:"";s:6:"layout";s:4377:"[{"cls":"full-col full-slider","bgcolor":"","bgimage":"","fullwidth":"1","parallax":"0","sfxcls":null,"padding":"","margin":"","iposition":null,"iattachment":null,"cols":

But after a simple modification, which are provided by the Opencart CMS, the entries in the database are like this:

{"status":"1","name":"Default","class":"","layout":"[{\"cls\":\"full-col full-slider\",\"bgcolor\":\"\",\"bgimage\":\"\",\"fullwidth\":\"1\",\"parallax\":\"0\",\"sfxcls\":null,\"padding\":\"\",\"margin\":\"\",\"iposition\":null,\"iattachment\":null,\"cols\":

And after all this I get the error: Notice: unserialize(): Error at offset 0 of 5472 bytes in /home3/trisoni2/public_html/ohappy/admin/model/extension/module.php on line 32

In what could be the cause of the error and how to fix it? Please help

  • 写回答

1条回答 默认 最新

  • douzhan1963 2016-05-12 13:12
    关注

    Something seems not alright here: the 2nd one is JSON but the 1st is a Serialized Object* You can tell from their signatures... Notice that the first one has Prefixes like a:, s:, i: The a: means that everything wrapped up in the Curly Braces following it is an Array. s stands for String and i for integer. Once you mess with this Structure, you have a Problem.... If your reverted the values to the first one, everything will work just fine again...

    I just convert the Second One (which is JSON) back into a PHP Serialized Data. So now, try replacing the content of the Table-Field with this Value - exactly as it is here:

    O:8:"stdClass":4:{s:6:"status";s:1:"1";s:4:"name";s:7:"Default";s:5:"class";s:0:"";s:6:"layout";a:1:{i:0;O:8:"stdClass":11:{s:3:"cls";s:20:"full-col full-slider";s:7:"bgcolor";s:0:"";s:7:"bgimage";s:0:"";s:9:"fullwidth";s:1:"1";s:8:"parallax";s:1:"0";s:6:"sfxcls";N;s:7:"padding";s:0:"";s:6:"margin";s:0:"";s:9:"iposition";N;s:11:"iattachment";N;s:4:"cols";N;}}}
    

    WARNING: Be sure you have a back-up of the Field somewhere before doing this...although it will still work... but just in case...

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

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?