Link to home
Start Free TrialLog in
Avatar of Ianaldo
Ianaldo

asked on

Urgent: insert doesnt display properly????

Ok, I have a form on a webpage, that collects data and sends it to an SQL query that inserts into the appropriate field in my MS Access DB, say if i input text in my form just like the way i have it below to actually display like that when i call it to a web page, below is what it looks like when i put it into the form, and after is what it looks like when i call it back from the database in another html page, by the way im using coldfusion and SQL to call the text from the database:


//What text looks like when i have wrote it into form, then submitted to DB:

Friendship Between Women:
A woman didn't come home one night. The next day she told her husband
That she had slept over at afriend's house. The man called his wife's 10
Best friends.
None of them knew about it.


Friendship Between Men:


A man didn't come home one night. The next day he told his wife that
He had slept over at friend's house. The woman called her husband's 10 best
Friend's.
Eight of them confirmed that he had slept over, and two
claimed that he was still there.



//What text looks like when i call it from the DB and display it to the screen:

A woman didn't come home one night. The next day she told her husband That she had slept over at afriend's house. The man called his wife's 10 Best friends. None of them knew about it. Friendship Between Men: A man didn't come home one night. The next day he told his wife that He had slept over at friend's house. The woman called her husband's 10 best Friend's. Eight of them confirmed that he had slept over, and two claimed that he was still there.


How do i get it to display the way i inputted it???

This is my SQL Code:

INSERT INTO editbook (editbook,userentry,user,[date])
VALUES
('#id#','#form.userentry#','#session.username2#','#DateFormat(Now(), "DD/MM/YYYY")#')

userentry is the field that the text gets inputted into.

Thanks,

Ian
Avatar of js_vaughan
js_vaughan

Do something like this:

<cfset userText = form.userentry>
<cfset userText = ReplaceList(inputstream,"#chr(13)#,#chr(10)#","<br>")>
<cfset userText = Replace(result,'  ',' &nbsp;','ALL')>
<cfset userText  = Trim(preserveSingleQuotes(userText))>

INSERT INTO editbook (editbook,userentry,user,[date])
VALUES('#id#','#userText#','#session.username2#','#DateFormat(Now(), "DD/MM/YYYY")#')
Avatar of Ianaldo

ASKER

Actually i just checked my DB, it inputs fine into the DB, but displaying it back to the screen is the problem, it join all the sentences and paragraphs together, when i look at the DB its in the "before format" like i have above, but when i output that to the screen using CF, its in the "after format"!?!?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of js_vaughan
js_vaughan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh ... one more thing ... the reason that I did it BEFORE hitting the database the first time is so that you dont have to run those 3 lines every single time the page is displayed to your visitors... you only have to run it once before it goes in (and do the reverse process if you have to output it back into a textarea for reformatting.)

Its just alot less work on the coldfusion server this way.  Just my 2 cents :-)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial