Saturday 26 September 2009

How to survive to 500 Internal Error

A website used by a PR company, after more than 900 articles imported, today had a new issue:
500 Internal Server Error

The first thing I thought was: maybe the article they posted was too long. They copy and paste by Word document, and there is a PHP filtering function that simplifies code in lighter HTML, deeply tested and working finely also in other projects.

I asked them to forward the original article, and it was not too long. Strangely, they said also they had posted other long articles in the past, without any issue. I looked for tips on the Internet, and I checked .htaccess file, configuration of server, but nothing. When I tried to post the article with only a paragraph, and adding a paragraph more for every new attempt, I was able to do it: but after a certain numbers of paragraph I had again that terrible message.

This convinced me that the issue was its width in bytes. Finally, I had an idea: could it depend on the encoding of the form? Well, I solved all as follows:
<form action="..." method="post" enctype="multipart/form-data">

Now it works!

Further reading: Forms in HTML documents