• 0

[PHP] Posting a Long String causes a 500 Internal Server Error


Question

I have a page which posts a large amount of text from one field and two other small fields which are then attempted to be written into a database.

Now with short strings this works fine, but with long strings it gives me a 500 Internal Server Error.

$escapedHTMLText = mysql_real_escape_string(ereg_replace("/\n\r|\r\n|\n|\r/", "", $_REQUEST['html_text']));
$escapedPageName = mysql_real_escape_string($_REQUEST['page_name']);
$pid = $_REQUEST['pid'];

$update_query = "UPDATE page_contents SET page_name='$escapedPageName', page_contents='$escapedHTMLText' WHERE page_id=$pid";

But even when the line that actually processes the long bit of text is surpressed and replaced with an empty string, the same error happens:

//$escapedHTMLText = mysql_real_escape_string(ereg_replace("/\n\r|\r\n|\n|\r/", "", $_REQUEST['html_text']));
$escapedHTMLText="";
$escapedPageName = mysql_real_escape_string($_REQUEST['page_name']);
$pid = $_REQUEST['pid'];

$update_query = "UPDATE page_contents SET page_name='$escapedPageName', page_contents='$escapedHTMLText' WHERE page_id=$pid";

Does anyone have any idea why this may be happening, and any other tips for improving this code (I am a PHP newb)???

It's driving me insane and I can't see anything wrong with it...

Thanks.

Fahim

5 answers to this question

Recommended Posts

  • 0

perhaps your ereg() is causing an infinite loop?

try replacing that line with the following:

$escapedHTMLText = str_replace("\n\r", '', $_REQUEST['html_text']);
$escapedHTMLText = str_replace("\r\n", '', $escapedHTMLText);
$escapedHTMLText = str_replace("\r", '', $escapedHTMLText);
$escapedHTMLText = mysql_real_escape_string($escapedHTMLText);

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.