Part of the EllisLab Network
   
 
Storing HTML in MySQL
Posted: 27 August 2008 12:09 PM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  198
Joined  02-25-2007

Hey guys,

Have any of you encountered a need to store html in your database. I am tasked with using a wysiwig editor and then saving this information in the database. Once a user accesses a certain page, I need to output the previously stored HTML.

Best way to do this, with or without TinyMCE?

Thanks!

Profile
 
 
Posted: 27 August 2008 12:27 PM   [ Ignore ]   [ # 1 ]  
Grad Student
Avatar
Rank
Total Posts:  81
Joined  09-13-2007

This is very common, actually.  I have used FCKEditor, mainly.  I like it because it allowed me to specify what tags I want to allow. 

You still have to check the text before you store it.  In my most recent system I’m building, I’m stripping out everything except H, P, A, B, Strong, I, and EM tags.  There are CI and PHP functions that are useful in stripping out illegal chars… you can use all sorts of regex checks as well.

I haven’t used TinyMCE, but I would guess it’s similar to FCKEditor.  So to answer your question…. why not use both?  An editor AND backend processing.  You can’t be too safe.

While you’re at it, either use authentication, or a CAPTCHA to stop the form spammers.

Profile
 
 
Posted: 27 August 2008 12:55 PM   [ Ignore ]   [ # 2 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2519
Joined  06-11-2007

I have done a lot of work with TinyMCE and find it to be over engineered and slighly buggy. It could just be because we’re using an old version which im not allowed to upgrade, but im still not much of a fan.

Worth a try is Spaw which is a very simple and looks brilliant.

 Signature 

Blog | Twitter | GitHub
————————-
CodeIgniter 2: Everything you need to know
————————
PyroCMS - open source modular CMS built with CodeIgniter
CleverAndy - get money for un-used concept designs
————————
Libraries: Asset, Dwoo, Cache, cURL, CLI, REST, Template

Profile
 
 
Posted: 27 August 2008 02:45 PM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  189
Joined  09-12-2007

I use TinyMCE. I also validate using the validation class. I am confused by your question. What is it that you are asking?
Is TinyMCE a decent wysiwyg editor? - sure, preferences may steer you to other editors, but you should be able to use it.
Is TinyMCE a decent way to validate the code? I doubt it. You should always validate it on the server.

If those aren’t your questions, please reply and clarify.

 Signature 

Voltamp Media
Web: PHP, MySQL, PERL, HTML, CSS, Python, Javascript
Linux: FreeBSD, OpenVPN, SMB, SVN, C, Shell

Profile
 
 
Posted: 28 August 2008 10:13 AM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  198
Joined  02-25-2007
Eric Cope - 27 August 2008 02:45 PM

Clarify question/quote]

My question is specifically how to validate HTML code.

Profile
 
 
Posted: 28 August 2008 10:56 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  189
Joined  09-12-2007

Are you looking to validate all HTML code, or a small subset? If its only a small subset, then a preg_match statement for each tag may be sufficient.  You could always integrate an external class like this:

http://twineproject.sourceforge.net/doc/phphtml.html

 Signature 

Voltamp Media
Web: PHP, MySQL, PERL, HTML, CSS, Python, Javascript
Linux: FreeBSD, OpenVPN, SMB, SVN, C, Shell

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120604 Total Logged-in Users: 43
Total Topics: 126642 Total Anonymous Users: 2
Total Replies: 665701 Total Guests: 492
Total Posts: 792343    
Members ( View Memberlist )
Newest Members:  bell143paololukDarleneChadbourneRashadSargIvar89lhumphris18aHonschowmtRetliff