Time warp via bad SQL

So I open up my site today and it's showing stuff from October 2005. Having not changed my SQL queries in a long time I initially thought someone had hacked my site or I had left PHPMyAdmin open and people went on a delete raid. Thankfully as I check out the archives everything was still there, albeit in almost reverse chronological order.

It took a few minutes to find the source of the issue. Most of my queries have an ORDER BY clause in them, "ORDER BY 'date' DESC" where 'date' is a column in my table. Something must have been upgraded on my shared server because it definitely doesn't like 'date' being wrapped in single quotes. So I dropped the quotes in at least 10 places and everything should be back to normal. RSS feed isn't showing the oldest stories any more (woot).

If I am hosting your site, then you may want to take a quick tour around your stuff and make sure it's all in order. If I missed anything let me know.

3 Comments