SQL apostrophe problems

Discussion in 'PHP' started by bdunndchi, Aug 1, 2008.

  1. #1
    This may be a stupid question, but...

    How do I get an apostrophe (') to show up as an apostrophe instead of a ? when I display it on screen. I have it saved as a VARCHAR in my database, and when I send it to the screen with PHP, it shows up as a ? in the words instead of an apostrophe.

    Thanks for any help.
     
    bdunndchi, Aug 1, 2008 IP
  2. Handsofmodder

    Handsofmodder Peon

    Messages:
    177
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I may be wrong, but to display an apostrophe, you need a backslash with it. \'
     
    Handsofmodder, Aug 1, 2008 IP
  3. bdunndchi

    bdunndchi Member

    Messages:
    91
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    Ok thanks. I'll try that. I actually figured out a way to do it with replacing the apostrophe with "’"

    I'll give your way a shot too.

    Thanks.
     
    bdunndchi, Aug 1, 2008 IP
  4. whirlybird20

    whirlybird20 Guest

    Messages:
    462
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think you just need to put a \ before it. The same thing with commas.
     
    whirlybird20, Aug 2, 2008 IP
  5. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #5
    If you are displaying it on html page then use htmlspecialchars() with ENT_QUOTES as a 2nd parameter.
     
    mwasif, Aug 2, 2008 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    I don't think the quote was an ASCII character. Did you copy the text from a Word document or something?
     
    nico_swd, Aug 2, 2008 IP