It's impressive that it works, but yes, it could probably be a lot shorter.
If I can drag myself away from World of Warcraft for a couple of hours this afternoon, I'll try and do a bit more work on that mysqli/prepared statements tutorial I was planning to write. Then you can kiss goodbye to having to filter/escape everything.