Results 1 to 2 of 2

Thread: MYSQL problem with speech marks

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    MYSQL problem with speech marks

    Every time i try to insert a string which contains a single quote I get a nasty error message.

    How do you guys get around this ?

    Do I have to write code to find and replace or is there another way ?

    Parksie

  2. #2
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770
    A single quote is a special character in most DBMS. You have to, and should, excape all DB related special characters in any data you plan to UPDATE or INSERT.

    If you are using MySQL, here is a string reference for special characters: http://www.mysql.com/doc/en/String_syntax.html

    The single quote also applies to other DBMS such as MS Acces, MS SQL Server, Oracle, etc.. Look in their references guides.

    A simple find and replace would do just wonderful.

    Code:
    newstr = Replace(datatobeinserted, "'", "''")
    
    '-In other words,
    
    newstr = Replace(datadobeinserted, Chr(34), Chr(34) & Chr(34))

    Hope I have helped.

Posting Permissions

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



Click Here to Expand Forum to Full Width