MySQL easy syntax question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Socks
    Confirmed User
    • May 2002
    • 8475

    #1

    MySQL easy syntax question

    update category_text set text='this is a problem because it's got an apostrophe in it', keywords='asdf,asdf' where id='1';

    Just that the string I want to insert has an apostrophe.. Is that going to mess the syntax up?
  • jMEGA
    Confirmed User
    • Oct 2005
    • 671

    #2
    try this

    update category_text set text='this is a problem because it\'s got an apostrophe in it', keywords='asdf,asdf' where id='1';
    Design | SEO | Photo / Video Editing
    ( ICQ 49354667 )

    Comment

    • Socks
      Confirmed User
      • May 2002
      • 8475

      #3
      Nice thanks!! Now I know why I've seen those things printed around my site sometimes heh

      Comment

      • V_RocKs
        Damn Right I Kiss Ass!
        • Nov 2003
        • 32449

        #4
        google for php html entities

        Comment

        • nation-x
          Confirmed User
          • Mar 2004
          • 5370

          #5
          if this is for a php script then you can just use http://us3.php.net/mysql_real_escape_string

          Code:
          $sql = "update category_text set text='".mysql_real_escape_string("this is a problem because it's got an apostrophe in it")."', keywords='asdf,asdf' where id='1';"
          
          $affected_rows = mysql_query($sql);
          Last edited by nation-x; 04-04-2009, 07:03 AM.

          Comment

          Working...