Forum Moderators: coopster

Message Too Old, No Replies

best way to strip tags

         

supermanjnk

6:22 pm on Feb 8, 2005 (gmt 0)

10+ Year Member



I have a message board of sorts where users can post to it, I'd like to know what the best way to strip the tags would be. for example

all < would become &gt; and all > would become &lt;

yowza

6:36 pm on Feb 8, 2005 (gmt 0)

10+ Year Member



htmlentities()

supermanjnk

12:10 pm on Feb 10, 2005 (gmt 0)

10+ Year Member



if i'm posting it to a mysql database, is it better to strip the tags before I put it into the database, or on the fly?

dreamcatcher

1:17 pm on Feb 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Definitely before you add the data to your database, as some things, such as apostrophes may cause a problem. It increases SQL efficiency.

hakre

1:31 pm on Feb 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if i'm posting it to a mysql database, is it better to strip the tags before I put it into the database, or on the fly?

to strip tags means to remove them. so i assume you want to convert the 2 special characters into their html entities (like written above, you can use htmlspecialchars() for your prob, too).

for a mysql database, there is no need to change the characters before putting the text into the db. for a database it's gernerally a good practise not to put information into it, which is not needed (&lt; instead of > makes 4 chars out of 1). because of this and some other reasons (compability, bugs in functions etc. pp.) i would suggest you to use "on the fly" [at the ouput].