Link to home
Start Free TrialLog in
Avatar of jstohler
jstohler

asked on

Code cuts off input at apostrophe(')

When sending form data to my database, sometimes the input gets cut off if there's an apostrophe. E.g.: "Bob's House of Fun" makes it to the database only as "Bob". Is there an easy fix for this?
ASKER CERTIFIED SOLUTION
Avatar of CoolAss
CoolAss

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
Avatar of CoolAss
CoolAss

Wow... guess I typed to fast.

The above should be:

Simply use the VBScript replace command to replace every ' (single apostrophe) with a '' (double apostrophe). This will prevent termination of the code.

As in:

MySQLString = "Bob's House of Goats"

Replace MySQLString, "'", "''"

objRS.Open MySQLString

or

MySQLString = Replace(MySQLString, "'", "''")

objRS.Open MySQLString

Both with work.


Avatar of jstohler

ASKER

I never used replace before, but it looks easy enough. Can I use a line like:

objRec("Sitename") = replace(Request.Form("requiredSiteName")"'","''")

or does it need to be an independent command?
Sure... that will work fine.
Thanks! Great response time, too.