1

I am getting the following error :-

Message: unserialize() function.unserialize: Error at offset 65517 of 65535 bytes

Does the unserialize have a maximum size?

Here is the line in question within my PHP:

$array = unserialize($emails);

// this is the output of $emails (not all of it as it is huge)
string(65535) "a:12134:{i:0;s:29:"[email protected] ";i:1;s:31:"[email protected] "
5
  • I don't think it does. You need to provide more info about where your data is coming from Commented Sep 2, 2011 at 8:04
  • 4
    No, it has not. But guessing from that error message the source of your serialized string had a size limit (TEXT columns are limited to 64K). Commented Sep 2, 2011 at 8:04
  • 1
    no, they do not (and from what I've [found][1], they can serialize huge strings). They are limited in memory though, which does not seem to be your problem. Could you post the string you try to serialize / unserialize? [1]: php.net/manual/en/function.serialize.php#79339 Commented Sep 2, 2011 at 8:05
  • Is this data comming from DB having BLOB/TEXT type? Commented Sep 2, 2011 at 8:07
  • not sure why someone gave me a negative i thought my question was fairly clear.. oh well no to worry it isnt the end of the world :-) Commented Sep 2, 2011 at 8:45

2 Answers 2

14

The database field (presumably) that you're storing your serialized data into has a size limit which is exceeded by the length of that string - basically, your data is corrupted.

Sign up to request clarification or add additional context in comments.

5 Comments

the field structure was set to 'TEXT' doh! Do you recommend that I use a BLOB instead for this field?
Which btw, besides being too short for your case, is incorrect for another reason too. You can run into problems with character encodings - serialized data should be stored in a binary field.
@Gav every email address ought to be stored in separate field - that's the only proper solution!
@Col you are prob right its a legacy system which i've not built so im just keeping my changes to the system minimal, but i may look into doing that in the future thanks :)
I have a similar problem, I found out that json_encode is about 40% more space efficient so it is a better solution
3

You probably store this in a TEXT field in the mysql database. It's maximum size is 65,535 bytes, as in your error.

You can use MEDIUMTEXT, which is the next available.

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.