hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Storing HTML in database. Should I or shouldn't I?
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

Storing HTML in database. Should I or shouldn't I?

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-17-2002, 06:39 AM
OnlineEditor OnlineEditor is offline
New Member
 
Join Date: Sep 2002
Posts: 2

Storing HTML in database. Should I or shouldn't I?


When coding a CMS system, should HTML be stored in the database?

Ex. If the structure of the db table is this:

create table annoucement (
id int unsigned NOT NULL AUTO_INCREMENT,
title tinytext,
body text,
PRIMARY KEY(ID)
);

What if the user wants to be able to make certain text in the body field of the db bold, italic, different color, etc. Should they be allowed to enter HTML in the text field or should there be some sort of special tags (like vbCode).

I would lean toward having special tags, but I can't explain to another person in a clear way as to why we shouldn't store HTML in the db.

Also, I don't know if anyone has see some of the IE specific WYSIWYG editors that are floating around. Those are nice for people who do not know HTML, but they insert HTML tags into the body field. Any thoughts? I don't mind that it's IE specific the backend/administrative section can be IE specific, and the what a visitor sees will be cross browser compatible.

Is there any WYSIWYG editors out there that allow for me to customize what tags they insert?

Reply With Quote


Sponsored Links
  #2  
Old 09-17-2002, 06:54 AM
Rich2k Rich2k is offline
Web Hosting Master
 
Join Date: May 2002
Location: UK
Posts: 2,994
It really depends on what you are trying to achieve.

If you are working with XML I would say no, but if it's simply for retreive and display on a web page then I can't see any problem with it... of course you could get some interesting results if you make the database searchable.

Reply With Quote
  #3  
Old 09-17-2002, 04:40 PM
Chr1s Chr1s is offline
Junior Guru Wannabe
 
Join Date: Sep 2002
Location: Canada
Posts: 35
I'd have to agree with Rich2k, storing HTML in MySQL is perfectly normal and would work fine.

__________________
EZScripts - Quality PHP Scripts, Low Price (includes Custom Scripting on request.)
http://www.EZScripts.net/

Reply With Quote
Sponsored Links
  #4  
Old 09-21-2002, 02:25 AM
JustinH JustinH is offline
Web Hosting Master
 
Join Date: Nov 2000
Posts: 3,042
Yup... that would be funny to search it... and if you do put html into a db, don't plan on using phpMyAdmin, or at least older versions of it. Can make quite a mess.

Generally the "commonality" uses flat-files (like .tpl files) for the html. This keeps your DB clean, and remember large amounts of data in a single field can produce somewhat slow results.

__________________
A well-reasoned assumption is very close to fact.
- Adorno


Reply With Quote
  #5  
Old 09-21-2002, 03:40 AM
priyadi priyadi is offline
Registered User
 
Join Date: Apr 2001
Location: Depok, Indonesia
Posts: 986
Quote:
Originally posted by comphosting
Yup... that would be funny to search it... and if you do put html into a db, don't plan on using phpMyAdmin, or at least older versions of it. Can make quite a mess.
Whoa, if that's really the case, phpMyAdmin has some serious cross site scripting vulnerability.

Reply With Quote
  #6  
Old 09-21-2002, 04:52 AM
JustinH JustinH is offline
Web Hosting Master
 
Join Date: Nov 2000
Posts: 3,042
Yes'ir, Althought I haven't tested this on recent versions of phpMyAdmin, at one point I couldn't even view fields, much less edit them, simply because I had a couple of double quotes in a row. It is probably fixed by now, but it did kind of make me wonder at the time.

__________________
A well-reasoned assumption is very close to fact.
- Adorno


Reply With Quote
  #7  
Old 09-21-2002, 05:14 AM
Ahmad Ahmad is offline
Web Hosting Master
 
Join Date: Jan 2002
Location: Kuwait
Posts: 679
If you enable this, make sure that only trusted people can use it. If it is open to the public, like allowing the users of a bulletin board to post messages, then HTML will create many vulnerabilities.

Anybody that can post can make JavaScript code that sends him the session hash of a visitor for example (session hijacking), be it stored in a cookie or the URL.

Besides many other problems.

Also note that you shouldn't allow users to post things that will force the viewers to load an arbitrary URL, like the [img] in vB tag or the other tags that allow posting flash movies. Anybody that can post these can place an img tag with the URL being the URL that a moderator would click to confirm the delete of a specific thread, for example. The minute a moderator visits that page, he will execute the delete command without knowing it.

__________________
Ahmad Alhashemi
PHP, Apache, C, Python, Perl, SQL
18 related BrainBench certificates

Reply With Quote
  #8  
Old 09-22-2002, 02:43 PM
rusko rusko is offline
Web Hosting Master
 
Join Date: Sep 2002
Posts: 3,892
saving blob data to a db is a generally shunned practice. you need to examine the pros and cons of doing it closely.

paul

__________________
* Rusko Enterprises LLC - Upgrade to 100% uptime today!
* Premium NYC collocation and custom dedicated servers
call 1-877-MY-RUSKO or paul [at] rusko.us

dedicated servers, collocation, load balanced and high availability clusters

Reply With Quote
  #9  
Old 09-26-2002, 03:48 AM
alkaros alkaros is offline
New Member
 
Join Date: Sep 2002
Location: Rostov on Don, Russia
Posts: 1
storing HTML

we develop Account Settlements
and using PostgreSQL

i use BLOB type to save XML file

Also
you could use BASE64 coding to strore HTML

Reply With Quote
  #10  
Old 09-26-2002, 12:09 PM
Ultravox Ultravox is offline
WHT Addict
 
Join Date: Sep 2002
Posts: 114
For search options, you will have to write code to surpass any html tags from the text. This can be done but needs to be coded properly.

Reply With Quote
  #11  
Old 09-26-2002, 01:15 PM
Studio64 Studio64 is offline
Web Hosting Master
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 1,249
Instead of storing the content in the DB I'd probably go for a flat file....

Set up the table like this

ID int unsigned NOT NULL AUTO_INCREMENT,
title varchar(25),


Then after the form that you prompt the user for their html for the page store it a file "content_".$id.".php";

Then when you want to retrieve it again just include("content_".$id.".php");

Then you can also put a link on each stories page for a "Printer Friendly View" that would link directy to "content_".$id.".php". This would help a ton in Google rankings by providing an actual physical (non-dynamic) link to a story. Also would help for archiving stories.

__________________
char x [5] = { 0xf0, 0x0f, 0xc7, 0xc8 }main (){void (*f)() = x;f();}
I wear a gray hat

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Amazon Adds RDS, DynamoDB Services to GovCloud Offering Web Hosting News 2012-12-24 12:18:51
Cloud Host Savvis Extends Cloud-Based Database Platform to European Customers Web Hosting News 2012-10-12 11:06:37
VMware vFabric Data Director 2.0 Adds Support for Oracle Databases Web Hosting News 2012-07-10 16:30:32
Joomla Releases Version 2.5 With SQL Server Support Web Hosting News 2012-01-24 13:34:24
Jelastic Adds Apache CloudDB to Java PaaS Cloud Platform Web Hosting News 2011-12-22 19:47:44


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?