+Fahim S. MVC Posted August 20, 2007 MVC Share Posted August 20, 2007 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 Link to comment https://www.neowin.net/forum/topic/582476-php-posting-a-long-string-causes-a-500-internal-server-error/ Share on other sites More sharing options...
0 +theblazingangel MVC Posted August 20, 2007 MVC Share Posted August 20, 2007 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); Link to comment https://www.neowin.net/forum/topic/582476-php-posting-a-long-string-causes-a-500-internal-server-error/#findComment-588793623 Share on other sites More sharing options...
0 +Fahim S. MVC Posted August 20, 2007 Author MVC Share Posted August 20, 2007 Doesn't explain the second case - i.e. with the line commented it still happens! Link to comment https://www.neowin.net/forum/topic/582476-php-posting-a-long-string-causes-a-500-internal-server-error/#findComment-588793631 Share on other sites More sharing options...
0 +theblazingangel MVC Posted August 20, 2007 MVC Share Posted August 20, 2007 oh, sorry, missed that i doubt it's a problem with your code, contact support! Link to comment https://www.neowin.net/forum/topic/582476-php-posting-a-long-string-causes-a-500-internal-server-error/#findComment-588793814 Share on other sites More sharing options...
0 PKHelloNasty Posted August 21, 2007 Share Posted August 21, 2007 Does it happen even if you don't push the value to mysql? What is the type on the database field your trying to push the long string to? Link to comment https://www.neowin.net/forum/topic/582476-php-posting-a-long-string-causes-a-500-internal-server-error/#findComment-588794065 Share on other sites More sharing options...
0 +Fahim S. MVC Posted August 21, 2007 Author MVC Share Posted August 21, 2007 It happens even if I do nothing with the posted value, see example 2. Link to comment https://www.neowin.net/forum/topic/582476-php-posting-a-long-string-causes-a-500-internal-server-error/#findComment-588794681 Share on other sites More sharing options...
Question
+Fahim S. MVC
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.
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:
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
Link to comment
https://www.neowin.net/forum/topic/582476-php-posting-a-long-string-causes-a-500-internal-server-error/Share on other sites
5 answers to this question
Recommended Posts