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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of apostophe in user comments gets error in update query 1

Status
Not open for further replies.

squirleegirl

Programmer
Jun 24, 2003
59
US
Hi!

I've got a section that the user needs to leave comments in. Everything works fine as long as the user doesn't use an apostrophe in their comments. This causes a syntax error in the update statement.

My code is simple - request the information from the form into a variable and use that variable in my update query (or insert).

Like I said, works fine if there are no apostrophes. Does anyone know how to work around this?

Thanks in advance,
Squirleegirl
 
replace(myVar,"'","''")

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Infact, you should do a quick keyword search or google search on sql injection - a very real way your database can be hacked.


sql = "INSERT myTable VALUES ('" & replace(request("myVar"),"'","''" & "')"

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top