Double quotes in VB Script - Classic ASP

Hi Experts,
I would like to import a value from my database into a text field:

<input type="text" name="Message" value="<%=rs("Message")%>">

The problem is that the text in the Message column contains double quotes, and my text box won't display anything after the first double quote. How could I solve this problem?

Thank you for your help
romsomIT DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
just double them up by doing a simple search and replace:
<input type="text" name="Message" value="<%=Replace( rs("Message"), """", """""" )%>">

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
romsomIT DeveloperAuthor Commented:
Hi Big Monty.
Unfortunately this didn't work. The message still stops at the double quote.
0
romsomIT DeveloperAuthor Commented:
I also tried this but it didn't work either:
<input type="text" name="Message" value="<%=Replace( rs("Message"),"'","''")%>">
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
note that I edited my previous answer, so that the 2nd parameter contained 6 quotes:

<input type="text" name="Message" value="<%=Replace( rs("Message"), """", """""" )%>">

Open in new window


if that doesn't work, something else is causing the html to show incorrectly. let's try something a bit easier to visualize:

<input type="text" name="Message" value="<%=Replace( rs("Message"), """", "&quot;" )%>">

Open in new window

0
romsomIT DeveloperAuthor Commented:
This worked: <input type="text" name="Message" value="<%=Replace( rs("Message"), """", "&quot;" )%>">
0
romsomIT DeveloperAuthor Commented:
Thank you very much; my problem is solved. I just had to replace it with &quot;
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
If you are saving this to your db, you can also do this conversion to your table.   Then your not putting anything potentially harmful to your db.  When you output, the &quot will convert to a viewable quote in  html.

long_string=request.form("long_string")
long_string= replace( long_string, """", "&quot;")

INSERT INTO myTable (field1) VALUES (long_string)
0
romsomIT DeveloperAuthor Commented:
Than you Scott.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.