ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 12th, 2012, 06:34 AM
waxxin waxxin is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 5 waxxin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 7 sec
Reputation Power: 0
Textarea(WYSIWYG text editor) - the html code generated won't save into my DB table..

Hi CF guys,

I have a text-area form on my page...and I made my text-area field like an Editor for my content to be able modify(font,headings,alignment etc).
But when I'm about to insert it to my DB table, insert won't continue.
I've set my table column as Long Text data-type....

I made some testing and debugging and found out that the problem is the generated code produced by my text editor. IS there any possible solution on this one? I badly needed to use the Text Editor and save values into my Database.


Any help or suggestions?

BTW...I used the Tiny MCE or the ckeditor =)

Reply With Quote
  #2  
Old July 12th, 2012, 08:37 AM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
Are you getting an error? What is actually happening when you try to do the insert?

Reply With Quote
  #3  
Old July 12th, 2012, 11:24 PM
waxxin waxxin is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 5 waxxin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 7 sec
Reputation Power: 0
Nope I'm not gettin any error. And I found that the html generated code were not completely saved into my table column.

For example, the generated html code were :
Code:
<h3 style="color:blue;">
	Marriott to open first Sri Lankan property</h3>
<p>
	<br />
	<strong>After</strong> signing an agreement with Weligama Hotel Properties Ltd, the Marriott Hotels & Resorts brand plan to open their first Sri Lankan hotel.</p>


When I actual checked my table-column on the DB, only the
Code:
<h3 style=

were saved.

That's the reason when I output the value on the page, the display is blank.

Any suggestions or help?

Thanks.

Reply With Quote
  #4  
Old July 12th, 2012, 11:55 PM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
The quotes in your string aren't escaped. Try using cfqueryparam, which should handle escaping the quotes automatically.

By the way, you should always use cfqueryparam for ANYTHING the user is sending into the database, to prevent SQL injection. You're also wide open for XSS exploits with this setup, since the user can enter arbitrary code into your form. So at minimum you'll want to check for any JavaScript in the incoming form data and strip it out.

Reply With Quote
  #5  
Old July 13th, 2012, 02:30 AM
waxxin waxxin is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 5 waxxin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 7 sec
Reputation Power: 0
Thanks for the tips.

I have used the<CFQUERYPARAM> tag on my query insert,
<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#form.f_content3#">
but im still getting the same problem/issue.

Thanks

Reply With Quote
  #6  
Old July 13th, 2012, 08:50 AM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
Hmm, what database are you using? Can you post the cfquery itself?

Reply With Quote
  #7  
Old July 15th, 2012, 10:17 PM
waxxin waxxin is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 5 waxxin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 7 sec
Reputation Power: 0
Hi,

I'm using the MySQL Database,(MyISAM engine), datatype is LONGTEXT.

And here's the insert statement.
Code:
<cfquery datasource="#ds#" name="q_insert">
	INSERT INTO tb_article
	(d_name,d_content)
	VALUES(
          <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#form.f_name#">,
          <cfqueryparam cfsqltype="cf_sql_longvarchar" value="#form.f_content#">
         )
</cfquery>


Any idea on my problem/issue? Thanks.

Reply With Quote
  #8  
Old July 15th, 2012, 10:56 PM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
If you do a

<cfdump var="#form.f_content#"><cfabort>

Just before the query and then run the page, do you see the full HTML text?

Also, if you turn on debugging for SQL, do you see the full HTML content in the debugging output for this query?

Just for fun, you could try using single quotes around the value, like:

<cfqueryparam cfsqltype="cf_sql_longvarchar" value='#form.f_content#'>

Reply With Quote
  #9  
Old July 18th, 2012, 10:27 PM
waxxin waxxin is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 5 waxxin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 7 sec
Reputation Power: 0
You are right, I need to play around a little on it.

Anyways, I found that generated codes breaks when I put them on a hidden textfield.
Because,I have a preview page before I insert them into DB, so I have to hide them in form before inserting it to the next page.

My solution for now is to remove the preview page, and insert immediately after Submit button is clicked. I'll display the preview page after insert, and they have an option for update.

Thanks!

Reply With Quote
  #10  
Old July 19th, 2012, 11:36 PM
cfSearching cfSearching is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 117 cfSearching User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 16 m 2 sec
Reputation Power: 6
Use HTMLEditFormat() to escape the value in your hidden field and it should carry over to the next page just fine.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Textarea(WYSIWYG text editor) - the html code generated won't save into my DB table..

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap