SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    USA
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql query browser...how do I ignore " within a SET statement?

    I'm trying run this in mySQL query browser

    Code:
    Update xcart_classes x
    Set classtext = "5 Year Protection <a href="javascript: void(0);" onclick="javascript: window.open('etp.htm','HELP_POPUP','width=406,height=261,toolbar=no,status=no,scrollbars=yes,resizable=no,menubar=no,location=no,direction=no');" class="PopupHelpLink">Learn More</a>"
    where Classtext = "Add 5-Year Extended Protection";
    Obviously it fails, and I'm pretty sure it's because of the double quotes on my SET statement...any idea on how to avoid that? Not sure if I'm describing it well ...

  2. #2
    SitePoint Addict
    Join Date
    May 2005
    Location
    London, ON
    Posts
    360
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try replacing the quotes with: &quot;

    Code:
    Update xcart_classes x
    Set classtext = "5 Year Protection <a href=&quot;javascript: void(0);&quot; onclick=&quot;javascript: window.open('etp.htm','HELP_POPUP','width=406,height=261,toolbar=no,status=no,scrollbars=yes,resizable=no,menubar=no,location=no,direction=no');&quot; class=&quot;PopupHelpLink&quot;>Learn More</a>"
    where Classtext = "Add 5-Year Extended Protection";
    Ryan Price
    Subscribe to my blog for regular tips and tricks

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    USA
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    simple, yet brilliant. Thank you sir.

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,267
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    unfortunately a href=&quot;http:// ... might not actually work

    here's the best practice solution:
    Code:
    Update xcart_classes x
    Set classtext = '5 Year Protection <a href="javascript: void(0);" onclick="javascript: window.open(''etp.htm'',''HELP_POPUP'',''width=406,height=261,toolbar=no,status=no,scrollbars=yes,resizable=no,menubar=no,location=no,direction=no'');" class="PopupHelpLink">Learn More</a>'
    where Classtext = 'Add 5-Year Extended Protection'
    notice that the entire string is delimited by single quotes -- this is the sql standard, and using doublequotes will fail in most database

    mysql supports the sql standard, but also lets you use doublequotes to delimit strings (apparently to stay compatible with *choke* access)

    inside the strings, doublequotes may be used like any other character

    it's only embedded single quotes that you need to worry about, and these are handled by coding two single quotes in succession -- again, this is the sql standard, which mysql supports

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Addict
    Join Date
    May 2005
    Location
    London, ON
    Posts
    360
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good to know, thanks for correcting me.
    Ryan Price
    Subscribe to my blog for regular tips and tricks

  6. #6
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    USA
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm, interesting. Actually, Jeanco, as simple a fix that was, that didn't work anyway because the field limited the number of characters I can put in there and so the whole thing wouldn't fit...I'm sure that's something I can change too though.

    r937, thank you, I'll try that


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
  •