Databases :: MySql :: mysql function to remove html code ? |
|||
| By: Nono |
Date: 11/06/2007 16:34:08 |
Points: 20 | Status: Answered Quality : Excellent |
| is there a mysql function to remove html code ? | |||
| By: VGR | Date: 11/06/2007 17:18:10 | Type : Answer |
|
| good point ;-) In PHP, of course you know, you've the strip_tags() function. You can feed it with a list of allowed (inocuous) tags like I, B and U so that SCRIPT, IFRAME and other "funny" stuff is stripped away. This won't solve the javascript issue on some tage, BTW. Be careful with it. Don't rely only on strip_tags() to "sanitize" user-input data. Also, ALWAYS addslash() data before writing to the DB, and as a last word, be warned against "magic quoting", it can lead to nasty surprises ;-) Now, back to your question. If you want to stay at the mysql level to strip tags from data, I see no obvious solution execpt using a carefully crafted and unmaintainable regexp using REGEXP (or RLIKE, see this mysql manual page )you could also, a bit similarly to strip_tags() in PHP, apply repeated and nested STR_REPLACE() calls so that unallowed tags are removed, leaving only the allowed (or forgotten ;-) ones in place. My best idea is to try a bit with mysql with the manual on LIKE, RLIKE, STR_REPLACE() under your eyes, then if not satisfied, to turn to PHP for doing the job with strip_tags(). best regards |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








