Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apostrophe problem!!!!!! 1

Status
Not open for further replies.

JazzLeg

Programmer
Aug 22, 2002
63
GB
Hi,
I am taking information from users via a text area, this data is then insert into a database.

However if the user use an apostrophe (') the Insert statement fails.

I would like to collect information with apostrophe's in it.

How can i get around this problem?

Thanks
 
I have no doubt that there is bound to be a correct way of doing this, however, what we did was that we created a function that exchanged ' for ` - it looks almost the same and no one was any the wiser (heh heh)

Hope it helps...
 
<%
server.htmlencode(&quot;textareaname&quot;)
%>

make sure page is saved as .asp

hth
mb
:) &quot;Where's the Ka-Boom? There's supposed to be an Earth-shattering Ka-Boom!&quot;
Marvin the Martian
 
jazzleg,

You need to replace the single quote with two single quotes.

myvar = replace( request.form(&quot;text&quot;), &quot;'&quot;, &quot;''&quot;)

fengshui_1998
 
We just had this problem at work, SQL Server and some other dBs don't like the single quote since it inteferes with some SQL statements. FengShui1998 has the popular solution that we used. Just make sure to reformat the string when you display it.
 
I dunno 'bout &quot;popular&quot; at all - FengShui1998's is simply the correct solution. As for &quot;reformatting for display?&quot; I think you miss the point - the data is stored properly (with a single apostrophe) and will certainly be retrieved that way.

Nuff said.

-------------------------------------------------------
&quot;Sometimes you guys scare the heck out of me.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top