Fix “500 Internal Error” in WordPress

I recently upgraded my WordPress installation to the latest version (2.8.6) and started running into issues with uploading images. Every time I tried using the Flash Uploader I would see

HTTP Error.

On trying to use the non-flash browser based uploader, I saw the following:

Error 500 – Internal server error
An internal server error has occured!
Please try again later.

I googled quite a bit and finally found a solution. This error can happen because of quite a few different reasons:

  1. Incompatible plugins
  2. Incorrect .htaccess file contents
  3. PHP running out of memory
  4. Incorrect file permissions
  5. Not using PHP5

Incompatible plugins

Easiest way to find if this is the issue is to deactivate all plug-ins and see if the issue still persists. If it goes away you can activate each plug-in one by one to find the culprit. You can read more on managing plug-ins here.

Incorrect .htaccess file contents

For some people, the issue went away after fixing the .htaccess file contents. You need to ensure that the .htaccess file at root of your website has the following contents:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

You can read more about it here.

PHP running out of Memory

This can happen if you are using some memory hungry plug-ins. You can fix this issue by adding a php.ini file in <wordpresss_root>/wp-admin folder with the following contents:

memory=20MB

You can read more about this at codedifferent.com, where this is explained in more details.

Incorrect file permissions

WordPress can start acting up if the permissions on directories and files in WordPress installation aren’t set up properly. You can ensure that this is fixed by logging into your hosting provider and making sure all files and directories have permissions set to 755.

Another issue that might lead to errors while uploading is certain security issues with files used for uploading. This can be fixed by using Image Upload HTTP Error Fix plug-in. Otherwise, you could edit .htaccess to add the following lines:

#BEGIN Image Upload HTTP Error Fix
<IfModule mod_security.c>
<Files async-upload.php>
SecFilterEngine Off
SecFilterScanPOST Off
</Files>
</IfModule>
<IfModule security_module>
<Files async-upload.php>
SecFilterEngine Off
SecFilterScanPOST Off
</Files>
</IfModule>
<IfModule security2_module>
<Files async-upload.php>
SecFilterEngine Off
SecFilterScanPOST Off
</Files>
</IfModule>
#END Image Upload HTTP Error Fix

Not using PHP5

Even after doing all the above, things weren’t working for me. That is when I came across this post, which explains that the issue could be because PHP5 wasn’t enabled. According to a help article on 1and1.com, fix is to just add the following line in .htaccess file:

#enable php5
AddType x-mapp-php5 .php

This fixed the issue for me!

Hope this helps.

Removing tags from WordPress posts content

I have been using WordPress since version 1.x and back then there was no native support for tags in WordPress. Easiest thing to add tags to post was to use UTW or other plugins and because of my new found love for tags then, I started using WP-Tagerati and then moved on to Ultimate Tag Warrior. Using these plug-ins meant adding custom tags such as

<tags>foo, bar</tags>

or

[tags]foobar[/tags]

into each post. The plug-ins would parse the post for these custom tags and then tags could be displayed using some APIs provided by the plug-in.

Since v2.3, wordpress now comes with built in support for Tags. This has eliminated the need for using the above mentioned plugins. So, I decided to get rid of them. On disabling the plugins, I noticed that the custom tags along with the tagging information were appearing as post content. To fix this issue, I initially started using Embedded Tag Thing but finally decided to get rid of the tagging information from the posts altogether. Before you do get rid of the tags, do make sure that you import them into wordpress’s tag data, so that you don’t loose this information totally.

Considering that you have a standard installation of WP, fixing this problem is a breeze if you don’t mind playing a bit with phpMyAdmin. Just do the following:

0. Backup WordPress
Backup you WP database. Always, backup your database before going in for direct manipulation of WP data. You can get a whole lot of information by reading about it here.

1. Download Posts table using phpMyAdmin
Go to the phpMyAdmin URL for you WP installation’s database. You can do this by using the very useful WP-phpMyAdmin plugin. As shown in the following screenshot, select the wordpress database that you have configured from the dropdown menu. And then select the wp_posts table. This will refresh the frame on the right side to display the wp_posts table.

Now, we are going to export the posts table. To do this, select the Export tab –> check the Add DROP TABLE checkbox –> hit Go. See the screenshot below.

This will take you to a page that contains a textbox with an SQL script in it. Copy the contents of the textbox and save them in a file.

2. Edit the file
Open the file in your favorite editor. You will see the SQL Dump that contains a lot of queries. Now, run a regex replace query on the content using the regex

\[tags\].+?\[/tags\]

This should go though you posts and remove all strings of the type [tags]foobar[/tags]. Change the regex to suit the way you have declared tags in your posts.

3. Import the file contents into wp_posts table
Go to phpMyAdmin and click on the import tab. See the screenshot for reference. Browse to the path where the modified file is located and just hit Go.

This should upload the file contents and execute the SQL queries in the file. If it fails and you see an error complaining about SQL_MODE being set to NO_AUTO_VALUE_ON_ZERO, just add a “” in front of the statement

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

to comment it out and then try to upload the file again. If things work out fine, you will see a message that says something like “X queries were successfully executed“.

There you go, you are done, If you check the posts contents now, you will not see the tags information. And no need to use any plugins to explicitly manage these tags anymore. Though I do suggest using Simple Tags to gain more control over your tag management.

HemingwayEx 1.5 Final

I finally got myself to fix some more bugs and add a couple of new things into the HemingwayEx WordPress theme. I received a few suggestions on features that could be added and after thinking about it a bit, I add some more things to this theme. This will (99.99%) be the last update of this theme coming out on my website. I have been intermittently updating this theme over the last year & a half and now I feel it’s time to move onto something else.

This update includes the following changes:

  • A new CSS with Black, Blue and Gray colors.
  • Added support for Paginating the homepage
  • Added WP Gravatar API into the comments. You can turn it on/off using WP->Settings->Discussion page.
  • Updated the theme to start using js included in WP itself.
  • Removed support for Hemingway blocks. Now, this theme only works with Widgets.
  • Fixed a few bugs reported by Thomas regarding the search page.

To get the theme go on over to the HemingwayEx download page.

It’s been a lot of fun working on this theme and I thank everyone who has used this theme and written to me about it.

Hemingwayex 1.1 is finally here

I have finally found time now and then in the past three weeks and tweaked HemingwayEx to work with WordPress 2.3+ and WordPress 2.5. I have fixed a lot of small issues here and there with CSS and the PHP code. I also added few more options to make the theme even more customizable. One can now choose to enable/disable sidebars, post navigation, excerpts on homepage, font resizer. Also, I have added in-built support for Related Posts plugin.

I would really like to thank people who have use this theme and have come back to me with bugs and ideas to improve HemingwayEx. Though I didn’t look at the emails/comments for a long time, I did go though all of them while working on this update. I have incorporated many comments and suggestions into this update.

I already have ideas for the next release, but I am sure that is ages away. Work has become so hectic that I have even stopped blogging regularly now. This will be my first post in almost half-a-year.

Anyways, I hope everyone who tries this theme has a good experience.

Thanks…

HemingwayEx 1.1 on it’s way

Tonight, I finally found it in me to fire up my XAMPP installation and make modifications to HemingwayEx. Things have again changed quite a bit in WordPress 2.3, especially with the way categories are handled now and the added support for Tags, and this means a lot of changes in the theme as well.

The major changes that I made are:

  1. Got rid of the ‘Check for Updates‘ feature. I never really got it to work properly, so I have gotten rid of it altogether. Also, I don’t see this theme changing so regularly that one would need to check for updates periodically.
  2. Got rid of the Asides feature. It was earlier possible to assign a category for Asides and then display those posts separately. But I haven’t really been able to add a whole lot more into this feature. Also, to use it, I had to provide a widget and a block implementation as well. I figure it is better for everyone to just use a plugin for setting up asides on their sites.
  3. Fixed Tagging, by replacing UTW functions with the native WP functions. This also meant that I have gotten rid of the Tag and Tags templates. Another thing that UTW provided was a way to display related post. I had to remove this as I couldn’t find a good plugin to replace this.

I am currently waiting to fixing some CSS issues and trying to figure out how to (and if I want to) add internationalization support. I don’t know when I would be able to find time for that…

Long long time ago…

Man…. it’s been ages since I have had a look at my site. I have been just too busy with work and lazy the rest of the time. My last post was on July 29th…

Finally, I upgraded to WP 2.3.1 tonight. As you can see (or might see), I am using the default WP theme right now as HemingwayEx doesn’t work with this version. I have been getting a lot of emails from people regarding this theme and many ppl have been enthu enough to go ahead and fix the theme to work with 2.3 as well. Hopefully, I will find sometime this weekend and do some work on it and answer questions in the forum.

Currently, I am eagerly looking forward to Dec and Jan. Both are going to be very eventful months. I am leaving for a three week trip to India in December and have other things coming up in Jan. Other than that, life is going on as usual… busy as hell on weekdays and boring/sad on weekends… 🙂

peace…

Say Hello to HemingwayEx 1.0

After about 4 months of inactivity little activity, I finally sat down sometime back and updated HemingwayEx. Added some much needed new features and squashed some old bugs. Again, a lot of help came from many others who have liked this forum and were nice enough to report bugs and give ideas of what more can be done with the theme.

Anyways, with this relase, HemingwayEx has made a major jump. The theme is now Widgetized. Users can now go to the options page and set whether they want to use the old blocks system or use widgets for sidebars. I have also added a font size changer and added comment numbering.

Going forward, I am planning on making the theme more customizable and adding internationalization support. Also, will work on adding more user styles.

Here are the pseudo release notes / changelog:

Version: 1.0
Release date: Jul 14, 2007
Release Notes: I have fixed a few more bugs. Also added some major features into the theme.

Added Features

  • Widgetized the theme. User can switch between using Hemingway Blocks System or Widgetized Sidebars.
  • Added a font size changer. Now viewers can increase / decrease the size of font by clicking on a few links just below the search form. Credit goes to this simple and easy tutorial.
  • Numbered comments, that look (IMHO) cool.
  • Added an Asides Widget to be used when theme is being used in widgetized mode. The functionality is the same as the Asides block previously added to HemingwayEx.
  • Added a new block WordSpew, thanks to Darwin.

Bug Fixes

  • Simple CSS fixes to style.css
  • Added more properties to white.css
  • Removed all PHP short tags. I think this time I got ’em all.
  • Fixed bugs pointed out by Darwin

Tested on : WordPress 2.1 and WordPress 2.2.1 with IE6, IE7 and Firefox

HemingwayEx 0.95 beta

I have updated HemingwayEx wordpress theme by adding some simple new features. I also made some bug fixes. The best thing about this update is that now users will see a notification of a new version on the HemingwayEx Option page. I really hope that this works. I am not much of a PHP coder… just hacked up what I could by reading Peter Harkins’s code for the wordpress plug-in Sociable.

I also fixed some more CSS issues with the white.css stylesheet. The worst part about styling a theme is making it compatible with different browsers. I must make my displeasure with IE’s handling of CSS very clear here. I have done what I can for now and will keep fixing things as I learn more.

You can download the latest version, 0.95 beta from HemingwayEx homepage.

If you are UPGRADING, you will need to reset/uninstall the previous version of HemingwayEx first as I have moved the blocks around. If you don’t you might find the display mixed up. Here are the steps you should follow:

  1. Goto HemingwayEx Options page and note down you settings.
  2. Now upload the new files for HemingwayEx theme.
  3. Click reset button right at the bottom of the HemingwayEx options page.
  4. Refresh the HemingwayEx Options page and set the options to what they were before.

Introducing HemingwayEx for WordPress

Finally, after quite a bit of tinkering with the Hemingway theme, I have come up with HemingwayEx, an extension of the Hemingway wordpress theme. It’s sort of a beta release as I have only tested it with WordPress 2.1 Ella and CSS support is mainly for Firefox. I have added quite a few new features, which makes it very different from other themes built on top of Hemingway, but it still preserves the essence of the original Hemingway theme.

I would love to hear from WP bloggers who give this theme a try. You can learn more about HemingwayEx here.

Installed Limit Post plugin

Up until now all the content of a post was being displayed on the index page. I didn’t like it that way and wanted each post to display only a certain number of characters and then have a link to the whole post. There is way to make it work when you use wordpress to create the posts, but I usually don’t do that. Even this post is being made using Blogjet. So I googled and found this plugin which does exactly that…

The only issue is that it’s not been implemented correctly. After certain posts that are truncated with certain HTML tags open, the rest of the document looses it’s formatting, usually getting italicised. I fixed the issue (partly) by editing the plugin. I changed line 40 from
echo "'>".$more_link_text."</a></p>";
to
echo "'>".$more_link_text."</a></em></strong></p>";

This ensure that the open tags for making the text italic and/or bold get closed for sure. It’s a very dirty hack, but has worked for me so far. Also, if you need your site to be valid for XHTML at all times, this is surely not the hack or even the plugin for you.