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
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...