944,193 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 1754
  • ASP RSS
Mar 10th, 2006
0

Problem with input

Expand Post »
Hello all!

I need to fill a database using microsoft access and sql in an asp page.

I need to check that the input is not exsit yet, so I use the following to create sql sentence:
tempsql = select * from table where filed= '"
tempsql = tempsql & request.form("name")
tempsql = tempsql & "'"

My problem is that I have to allow the input to include the sign ' ... it doesnt agree to acept it because of the field =' '...

In which other form can I get that input?
Thanks,
Plonter
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Plonter is offline Offline
1 posts
since Mar 2006
Mar 13th, 2006
0

Re: Problem with input

You will need to use a simple, yet essential, replace statement on your inputs to allow the use of quotes. This allows the users to input values such as O'Hare legitimately, and also prevents the simplest form of SQL Injection attack by the use of a ' to break the code. A simple function to replace quotes would be like:
ASP Syntax (Toggle Plain Text)
  1. function cleanString( string )
  2. '// replace single quotes
  3. strTemp = replace(string, "'", "''")
  4. '// replace quotes
  5. strTemp = replace(strTemp, """", """""")
  6. cleanString = strTemp
  7. end function
Reputation Points: 16
Solved Threads: 7
Junior Poster
Lafinboy is offline Offline
166 posts
since Jul 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: Merge two string
Next Thread in ASP Forum Timeline: How can i remove the comma?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC