user1133643
user1133643

Reputation: 29

How can I unserialize this string as its showing error at point 292?

this is my string in serialized form.when i tried to unserialized (convert to array) the string i was given error ,please see the following serialized string

a:6:{s:5:"width";s:3:"614";s:6:"height";s:3:"414";s:14:"hwstring_small";s:23:"height='86' width='128'";s:4:"file";s:171:"2011/02/Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok.jpg";s:5:"sizes";a:9:{s:9:"thumbnail";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-162x160.jpg";s:5:"width";s:3:"162";s:6:"height";s:3:"160";}s:6:"medium";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-258x173.jpg";s:5:"width";s:3:"258";s:6:"height";s:3:"173";}s:5:"large";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-530x357.jpg";s:5:"width";s:3:"530";s:6:"height";s:3:"357";}s:12:"post-special";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-530x380.jpg";s:5:"width";s:3:"530";s:6:"height";s:3:"380";}s:8:"post-top";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-110x110.jpg";s:5:"width";s:3:"110";s:6:"height";s:3:"110";}s:9:"post-tiny";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-108x100.jpg";s:5:"width";s:3:"108";s:6:"height";s:3:"100";}s:9:"post-item";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-455x327.jpg";s:5:"width";s:3:"455";s:6:"height";s:3:"327";}s:11:"post-review";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-162x166.jpg";s:5:"width";s:3:"162";s:6:"height";s:3:"166";}s:9:"post-poll";a:3:{s:4:"file";s:171:"Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-285x237.jpg";s:5:"width";s:3:"285";s:6:"height";s:3:"237";}}s:10:"image_meta";a:10:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";}}

i am getting error as

Notice: unserialize() [function.unserialize]: Error at offset 292 of 2873 bytes

please help and tell me what is the best what to serialize the string below is my original array

array (
  'width' => '614',
  'height' => '414',
  'hwstring_small' => 'height='86' width='128'',
  'file' => '2011/02/Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok.jpg',
  'sizes' => 
  array (
    'thumbnail' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-162x160.jpg',
      'width' => '162',
      'height' => '160',
    ),
    'medium' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-258x173.jpg',
      'width' => '258',
      'height' => '173',
    ),
    'large' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-530x357.jpg',
      'width' => '530',
      'height' => '357',
    ),
    'post-special' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-530x380.jpg',
      'width' => '530',
      'height' => '380',
    ),
    'post-top' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-110x110.jpg',
      'width' => '110',
      'height' => '110',
    ),
    'post-tiny' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-108x100.jpg',
      'width' => '108',
      'height' => '100',
    ),
    'post-item' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-455x327.jpg',
      'width' => '455',
      'height' => '327',
    ),
    'post-review' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-162x166.jpg',
      'width' => '162',
      'height' => '166',
    ),
    'post-poll' => 
    array (
      'file' => 'Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok-285x237.jpg',
      'width' => '285',
      'height' => '237',
    ),
  ),
  'image_meta' => 
  array (
    'aperture' => '0',
    'credit' => '',
    'camera' => '',
    'caption' => '',
    'created_timestamp' => '0',
    'copyright' => '',
    'focal_length' => '0',
    'iso' => '0',
    'shutter_speed' => '0',
    'title' => '',
  ),
)

thanks

//new data i did 171 to 169 when i json_encode('any image'); its giving null.

Upvotes: 0

Views: 231

Answers (1)

Cheery
Cheery

Reputation: 16214

Did you make any manipulations with serialized string? Any charset encoding (jumping from UTF to ASCII and vice versa), html entities encoding/decoding or something else? This

s:171:"2011/02/Classis-Pallela-from-Embrujo-Flamenco-at-97-Danforth-Ave.-We’ve-picked-the-classic-version-59-for-two-made-with-the-unique-and-super-absorbent-Bomba-rice.-ok.jpg"

should be 171 characters in length between the quotes, but it is only 169 characters long. And, of course, it will throw an error in the process of unserialization.

ps: check the length of the original string with that data.

Upvotes: 1

Related Questions