How to handle single quote in user input?

Results 1 to 5 of 5

Thread: How to handle single quote in user input?

  1. #1
    Join Date
    Dec 1969
    Posts
    57

    Default How to handle single quote in user input?

    I am new to ASP,<BR>Can anyone suggest me how to handle single quote in user input.<BR><BR>If user enters single quote in the input field such as <BR>Bill&#039s Monica, it gives syntax error on the sql statement.<BR><BR>Any quick fix?

  2. #2
    Join Date
    Dec 1969
    Posts
    168

    Default Replace single quotes with double quotes

    &#060;%<BR>&#039this will convert "Bill&#039s Monica" to "Bill&#039&#039s Monica" to insert into the database<BR><BR>&#039when you retrieve it from the db, it will only have one single quote<BR><BR>varname = replace(Request.Form("Name"),"&#039","&#039&#039") <BR>%&#062;<BR><BR>Hope this helps.. Cheers!

  3. #3
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: Replace single quotes with two single quotes

    Using the term double quotes is a bit confusing. You mean two single quotes. A double quote is ". A single quote is &#039. Two single quotes with a space between them are &#039 &#039.<BR><BR>There is an article on 4Guys that deals with this topic.<BR>http://www.4guysfromrolla.com/webtech/051899-1.shtml<BR><BR>Happy Programming!

  4. #4
    Join Date
    Dec 1969
    Posts
    572

    Default RE: How to handle single quote in user input?

    Check out:<BR>http://4guysfromrolla.com/webtech/051899-1.shtml


  5. #5
    boo Guest

    Default RE: How to handle single quote in user input?

    g

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •