SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    unserialize errors PHP 4 -> 5

    Hi All

    I have a slight issue I am porting a website from old hosting to new hosting - using exact same code and database just new servers I am seemingly not able to get the images displayed as the old site does - this is the lines of code in question and having never really used serialize before I was not sure if anyone knew if there was any issues with old PHP and new PHP with it?

    PHP Code:
        $image_list unserialize$product['image'] );
    echo 
    $image_list
    Thanks
    Sarah
    Regular user

  2. #2
    PHP Developer W1LL's Avatar
    Join Date
    Apr 2001
    Location
    Leicester, UK
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is the content of $product['image']?

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What was the error?, $product['image'] is a serialized data?

  4. #4
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I just get nothing - no error no nothing if I do this:

    PHP Code:
    echo '<p>' $kernel->html_chars$product['image'] ) . '</p>'
    then I see this is the serialized data

    a:59:{i:0;s:7:"9ra.jpg";i:1;s:7:"6ra.jpg";i:2;s:8:"10ra.jpg";i:3;s:8:"9100.JPG";i:4;s:15:"apache unit.jpg";i:5;s:17:"apache unit2..jpg";
    ....<snip>....
    ;i:58;s:12:"IMG_0051.JPG";}
    Regular user

  5. #5
    <?php while(!sleep()){code();} G.Schuster's Avatar
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Seems your serialized data is corrupt.
    >s:8:"9100.JPG "
    This is 9 chars including the space at the end but declared as 8

    If that's no copy'n'paste error you should really check your data.
    Oh, and regarding your "no error, no data" - unserialize() returns boolean FALSE upon data corruption and emits an E_NOTICE, so check your error_reporting-level.

  6. #6
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    wow so that is what they mean! damn this data was sent to me as I don't have mysql access on old hosting (hence they move!) damn thank you I will chase them now as I have seen other corrupt data and didn't think that would be the case here!
    Regular user

  7. #7
    SitePoint Evangelist simshaun's Avatar
    Join Date
    Apr 2008
    Location
    North Carolina
    Posts
    438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hopefully it was corrupt data that they sent you, because that will be easiest to remedy.

    I have seen this issue before though.

  8. #8
    SitePoint Enthusiast jameso's Avatar
    Join Date
    May 2002
    Location
    Melbourne, Australia
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would try pasting the serialized data in http://tools.perceptus.ca/text-wiz.php?ops=6 and see if it is able to unserialize it properly.

    If not, then the data is probably corrupted.

  9. #9
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys those links are very very helpful I am suggesting that I upgrade as the omments are quite right in that you should not be using PHP4 code that doesn't work in PHP5 as that would just cause so many issues within the future! Nightmare now for hopefully smooth(er) sailing in the future
    Regular user


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •