1. Replace ALL the single quotes in your DB with "'"
2. Replace ALL single quotes from requested variables with "'"
before making the call to the db
' translates to a single quote on the screen, and as another member mentioned is a start to save you from SQL injection attacks.
I personally don't use the classic ASP request object by itself - implementing the following method is A LOT easier when you start from scratch, but if you have time, it can be implemented afterwards as well.
This is a drilled down version of my entire object, you can add to it as you see fit, but once you understand how it works, it's easy to add to it to handle all requests (cookies, querystrings, forms). Place it in a separate file and referece it through an SSI.
Code:
<%
class requestObject
public function form(strInput)
dim theValue
theValue = server.HTMLEncode(request.form(strInput))
form = encode(theValue)
end function
' since not ALL the values are encoded using HTMLEncode, do additional ones here
private function encode(strInput)
dim strReturn
strReturn = strInput
encode = replace(strReturn,"'","'")
end function
end class
%>
initiate the object in your global header file, kill it in the global footer file.
Code:
<%
set req = new requestObject
myVar = req.form("myTBX")
set req = nothing
%>
Now, whenever ANYTHING is submitted through one of your forms, the above class will ensure any HTML special characters will be replaced with their HEX equivilant. So people can't even put HTML tags in the db or use malicious code to infect your db/server.
--------
GOOGLE is a great resource to find answers to questions like "how do i..."
--------