+1  A: 

This is where HTML Purifier comes in handy.

Sarfraz
+1  A: 

I would say that you don't have to strip any characters from your input, at least generally speaking.

Instead, you must escape your data :


Still, if you allow users to input HTML, you should take a look at HTMLPurifier, to make sure they are not able to inject any malicious HTML code into your web-pages :

HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive whitelist, it will also make sure your documents are standards compliant

Pascal MARTIN
“[…] to make sure they are able to inject any malicious HTML code […]” – Don’t you mean the opposite?
Gumbo
@Gumbo : ouch ; of course I mean the opposite ;-) ;; I've edited my answer to correct than ;; thanks for your comment !
Pascal MARTIN
htmlspecialchars can be dangerous for UTF-8 coded character sets
Sinan
A: 

Instead of sanitizing your data just use Prepared Statements for database interaction. PDOs eliminate the need of hand santizing all of your input yourself.

PHP Manual

ssergei
but aren't there other concerns besides just database interactions?
pedalpete