Home » questions » how do you allow tags to be saved in MYSQL?

how do you allow tags to be saved in MYSQL?

2006-08-09 13:09:17, Category: Programming & Design
hey, question again, how do you allow html tags to be saved in MYSQL?? say i have a textbox, and the info from that box gets sent to mysql... automatically, html tags get stripped before they get placed in the mysql base. i want them to stay, how do i avoid the automatic tag stripping of CERTAIN database fields??? so for example: i have a field called "aboutme" and a textbox on a page. users can enter upto 2500 characters in aboutme textbox, when subbmitted all gets sent to the aboutme field. say a user puts the following in the textbox: Hello, my name is DEMO<-br><-br>I like to eat lots!!!<-br><-br><-b>I'm 20<-/b> --- (btw, i put a - before each tag, so yahoo wouldnt read it as a tag ;-) ) now i want those tags (but in real format) to get saved to MySQL, so when i call that field (aboutme), it will show the html in format! please help, thanks alex best answer that works, gets 12pts thanks all! i cant believe it, it took me 1000 characters just for someone to say "it's in the php file!" and well and behold, IT IS! i had this thing that said "$aboutme = strip_tags($_POST[aboutme]);" than told the next command to set the field about me to $aboutme. next problem, does anyone know how to outlaw Javascript tags using php/mysql?

Answers

  1. DX

    On 2006-08-09 13:24:28


    make your php script print or echo the mysql result with the html code you want
  2. Interested Dude

    On 2006-08-09 13:29:36


    I find most html works fine when displayed with PHP. There are some exceptions, I think having to do with the handling of double and single quotes.
  3. jmfc

    On 2006-08-09 13:22:34


    sounds like something else is going on here. This wouldn't be a problem or issue with mySQL as it doesn't care what the text is that you are inserting into the fields and wouldn't strip out any characters. Do you have a script somewhere that may be stripping out HTML tags? We used to have one that processed all form fields to strip out 'bad' tags like this to prevent people from inserting javascirpt and stuff. Try submitting the data to another page and displaying it on that page. See if the tags are getting removed before it even hits the db. Also - have you looked directly at the data in the database to see if the problem is when the data is getting stored or when the data is getting displayed. Doesn't sound like a mySQL problem to me.