View Full Version : Rich Text Editor --linebreaks in Mysql (JS with classic asp)

12-29-2011, 04:03 AM
1) Script Title: rich text editor - linebreaks in mysql not allowing the editor to show up once updated..using classic asp coding, javascript for the editor and database mysql.

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex16/richtexteditor/index.htm but using the editor coding from http://www.kevinroth.com/rte/

3) Describe problem: I have searched and could not find an answer using a database

Creating an EDIT page using MySQL and Classic asp

using a query to request the information (but only going to include item description information here to simplicity sake

itemdesc = trim(rs("itemdesc")) <---pulled from database

<script language="JavaScript" type="text/javascript" src="cbrte/html2xhtml.min.js"></script>
<script language="JavaScript" type="text/javascript" src="cbrte/richtext_compressed.js"></script>
<script language="JavaScript" type="text/javascript">
function submitForm() {
//make sure hidden and iframe values are in sync for all rtes before submitting form
return true;


//Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML, encHTML)
initRTE("./cbrte/images/", "./cbrte/", "", true);
<noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>

<script language="JavaScript" type="text/javascript">
//build new richTextEditor
var rte1 = new richTextEditor('rte1');

if itemdesc = "" then
sContent = "here's the wonderhul " & chr(13) & " ""preloadededed <b>content</b>"" "
sContent = RTESafe(sContent)
sContent = itemdesc
end if

end if
rte1.html = '<%=(sContent)%>';
//rte1.toggleSrc = false;

function RTESafe(strText)

'returns safe code for preloading in the RTE
dim tmpString

tmpString = trim(strText)

'convert all types of single quotes
' tmpString = replace(tmpString, chr(145), chr(39))
' tmpString = replace(tmpString, chr(146), chr(39))
' tmpString = replace(tmpString, "'", "'")

'convert all types of double quotes
' tmpString = replace(tmpString, chr(147), chr(34))
' tmpString = replace(tmpString, chr(148), chr(34))
' tmpString = replace(tmpString, """", "\""")

'replace carriage returns & line feeds
' tmpString = replace(tmpString, chr(10), " ")
' tmpString = replace(tmpString, chr(13), " ")

RTESafe = trim(tmpString)

end function
'Response.write RTESafe &"<br>"
'response.write sContent &"<br>"

OK...the problem is that when if first enter the information it will add it as below:
UPDATE products Set itemdesc='
testing this out to see what<b> happens again now t</b>his is the real test

', WHERE itemid = 1

Because of the linebreaks that you see, when I go back to the edit page the rich text editor will not now up AT ALL.
If i go to the database and manually update or delete the linebreaks it will work fine.

it needs to be without any spacing:
UPDATE products Set itemdesc='testing this out to see what<b> happens again now t</b>his is the real test', WHERE itemid = 1

I have tried using the trim() coding everywhere and still no luck. The form will put the breaks in and it's an empty like above