views:

210

answers:

2

Hi, I have this script that fetches some data from mysql and then uses echo to output it. But, as the page have grown and gotten longer all of a sudden i have this weird behavior where it cuts of the end at 65535 chrs (when using strlen to check)

The data is all saved in MySQL, beyond the 65535 chrs showing when using echo.
EDIT: Sorry, it seems like NOT all data was saved, it was my WYSIWYG editor that made it look like all was saved but it wasent. (It auto closed unclosed tags making it look all ok when i opend the content again.)

Why is this happening?

All I do is;

$content= $row['content'];
echo $content;
+7  A: 

Are you sure it's a PHP issue? The MySQL TEXT field has a maximum size of 65535 characters. Make sure the text is actually in your database.

Scott Saunders
Oh! there we have our problem. Thing is I am using a WYSIWYG editor and tables.... oh nevermind... It ended up looking OK in editor but now i see, the text was not saved. Can I use something else than TEXT in MySQL to save text data bigger than 65k?
jamietelin
`MEDIUMTEXT` or `LONGTEXT`?
Douwe Maan
You can save it as a mediumtext which ups it to 2^24 or longtext which ups it to 2^32 bytes
thetaiko
MEDIUMTEXT and LONGTEXT will give you more space.
Scott Saunders
Thank you all very much!
jamietelin
A: 

Certainly sounds like a length limit. You could always try something like this:

$content = str_split($row['content'], 65536)
foreach ($part in $content) {
    echo $part
}
Sionide21