Forum Moderators: open

Message Too Old, No Replies

how to store html contain in database

         

Swapna

8:15 am on Apr 16, 2007 (gmt 0)

10+ Year Member



hello

how to store the html format in database side ( Sql server)

example if i want to get hello in bold letter what is the command is used to store the database side.

spikernum1

3:00 pm on Apr 16, 2007 (gmt 0)

10+ Year Member



<b>Hello</b>

as a text type

Discovery

3:44 pm on Apr 16, 2007 (gmt 0)

10+ Year Member



i also think text would be correct, because most to the cms using text data type to store content.

syber

6:41 pm on Apr 17, 2007 (gmt 0)

10+ Year Member



If your HTML will be less than 8000 bytes, VARCHAR(8000) as a datatype will be easier to work with.

justageek

2:09 pm on Apr 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Remember that as of 5.0.3 you can make a varchar up to 65535 characters long. It'll be less if you have more columns since 65535 is the max row size as well.

JAG

Swapna

8:08 am on Apr 19, 2007 (gmt 0)

10+ Year Member



hello

how to store the html format. Example if user want to click hello in bold letter. In database side it will store like this &lt;strong&gt;hello&lt;/strong&gt; in another page it will display like <strong>hello</strong> . I am using datatype is varchar(8000). but i am not getting the result as hello in bold letter.

Demaestro

6:23 pm on Apr 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This actually depends on your scripting language and how it compiles.

Some languages will render all the dynamic scripting first and then it will compile the HTML. Others will compile the HTML and then perform the dynamic scripting. Once both these things have happened regardless of order it will then send the file to the users' browser.

So when you have HTML being called into the page as a string the compiler may have already rendered the HTML so another argument is required to tell it that the string is not plain text but is text/html content type.

I don't know what language you are using but it usually looks something like this.

string_with_html = "<strong>Title</strong>"

<span content="structure string_with_html" />

The argument "structure" is called before the call to the variable, this tells the compiler that there is more html to render.

An example of it not rendering what should be an HTML tag is this very post.... clearly i have embedded HTML here and this post is living in a DB or some sort of flat file and is being called into this page but it has only been rendered in plain text. An addition argument would be needed to tell this page that the HTML tags in these posts are to be rendered as HTML. Clearly they aren't.

I hope this makes sense. The issue is not how you store it, the issue is how you are calling it into the page.... You are most likely calling it into the page as plain text. You will most likely need an extra argument somewhere to let it know that the text contained in the string is to be rendered as HTML.

Edit for speeling

[edited by: Demaestro at 6:34 pm (utc) on April 19, 2007]