HTMLPurifier
Download it here: http://htmlpurifier.org/
Turn it on:
include 'path/to/HTMLPurifier.auto.php';
Use it:
$config = HTMLPurifier_Config::createDefault();
$config->set('Core', 'Encoding', 'UTF-8');
$config->set('XHTML', 'Doctype', 'XHTML 1.0 Strict');
$purifier = new HTMLPurifier($config);
$clean_html = $purifier->purify( $dirty_html );
And sleep well, knowing that HTML doesn't have XSS attacks like this fixed.
, mysql_real_escape_string(), , ( ), , HTML- WYSIWYG, .
mysql_real_escape_string() SQL-, (google "PDO" ) .