SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Nov 2009
    Posts
    471
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Embedding quotation marks in a sql string field

    I have a string value that for example says

    Code MySQL:
    insert into t1 (textval) values ("Joe Smith of the NY Times says 'here is my quote and he said "this" to me and I can't say any more.");

    If I escape all the interior quote with \' or \" when it renders in the browser it is showing little boxes or the Firefox FF something square box but does not render the quotation marks. What am I doing wrong?

    Thanks

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,014
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    Code:
    insert into t1 (textval) values 
    ( 'Joe Smith of the NY Times says "Here is my quote and he said ''this'' to me and I can''t say any more."' );
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Evangelist
    Join Date
    Nov 2009
    Posts
    471
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, just noticed that I had left that single quote off at the end. I think I follow it. I'll let you know if I bump into any issues but it seems pretty straight forward. Thanks again as always, big help.

    One more question though. If I need to use multiple double quotes inside, say in quoting magazine names, do I just use them in pairs. Do they need to be escaped in that case? Or are they just ignored as any other character since they are inside the controlling single quotes?

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,014
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by bostboy View Post
    If I need to use multiple double quotes inside, say in quoting magazine names, do I just use them in pairs. Do they need to be escaped in that case?
    huh? example please?
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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