In this question, the OP realises he has a problem with trying to store user-supplied HTML in a database and is looking for a way to sanitise it.
Although the accepted answer looks valid on the surface, it's wholly inappropriate to use with unsanitised data, and leads to exactly the same problems the OP was worried about.
Is a down vote and large, bold warning enough in this case? The answer is quite long and my comment will almost certainly be below the fold, so it will not necessarily be completely visible to anyone looking in the future.