I’ve been searching for ages and can’t find this precise problem, but feel free to point me in the right direction if it has.
Simple Description: have a page that has a TEXTAREA on it. This TEXTAREA is to accept HTML as it’s used to edit the home page of a client’s website.
The aim is for this TEXTAREA to save to a VERY simple mySQL table.
PROBLEM: The problem is that if the TEXTAREA exceeds 512 characters is saves nothing to the database field. Under that it stores it fine.
Here’s the code:
$homeTopLeft = addslashes(htmlentities($_GET['homeTopLeft'], ENT_QUOTES | ENT_IGNORE, "UTF-8"));
$homeNews = addslashes(htmlentities($_GET['homeNews'], ENT_QUOTES | ENT_IGNORE, "UTF-8"));
mysql_login();
$query = "UPDATE cmsData SET homeTopLeft='$homeTopLeft', homeNews='$homeNews', lastUpdated=NOW() WHERE entry=1";
$result = mysql_query($query) or die(reportError('Unable to save new CMS data'));
if (mysql_affected_rows() > 0) {
echo '<p class="ok">Pages Successfully Updated!</p>';
echo '<p style="border:1px dashed #ccc;">homeTopLeft = ' . $homeTopLeft . '</p>';
} else {
echo '<p class="err">Unable to update the home page</p>';
}
I currently have the $_GET method as I’m actually calling the function via AJAX, which works fine under 512 characters.
What It’s Not
– It’s not the mySQL field size: Its data type is TEXT and I’ve manually increased the field through phpMyAdmin without error.
– It’s not (as far as I can tell) the AJAX call, because it works if the TEXTAREA is < 512 Bytes
– The Collation (I don’t think: I have it set to latin1_general_ci and have tried latin1_bin and some of the UFT ones)
Final Note
The actual database size of the field homeTopLeft has to be greater than 512 Bytes because of the htmlentities call.
I should also add that this occurs whether I’m just using a plain TEXTAREA or a tinyMCE rich text editor.
Any help you could offer would be gratefully received. Thanks!
There is a size limit on GET requests. For large things such as this, use POST