0

I'm creating a database with what I anticipate will be a long (perhaps several paragraphs for some tuples) attribute. I'm assigning it text instead of varchar. I have two questions:

  1. Should I give a maximum value for the text field? Is this necessary? Is it useful?
  2. Since the contents of this field will be displayed on a website in HTML, do I need to include paragraph tags for paragraph formatting when I enter records into mysql?

4 Answers 4

3
  1. Not really, define as text.
  2. If you want to display text in HTML with formatting you will either have to build the HTML tags into the text in the database or parse before printing and add them then.
Sign up to request clarification or add additional context in comments.

Comments

1
  1. No define it as text or mediumtext
  2. If the data will be output as HTML, store HTML tags

Comments

0

1) I do not give max length for fields that I place HTML in, as it is variable and could always grow longer. 2) I would place all HTML in the field, but it depends on if you want to do that extra step in your application.

NOTES: Always HTML encode your HTML data before inserting to database.

Comments

0

text field nas no length parameter.
enter whatever you with as long as it displays correctly

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.