" and ' in my mysql table are showing up as � on the site.

Discussion in 'PHP' started by enephs, Mar 18, 2011.

  1. #1
    I have some 400 word articles in mysql table containing a few random quotes here or there like: "blah" or 'blah'.

    When I call on the table to be displayed it displays the contents of the article but each quote inside is displayed like this: �blah� or �blah�.

    I've tried a few different ways of displaying it with no luck, I think i have the wrong idea of what needs to be fixed.

    If it helps I am currently not using "echo" to display the article. I am using sprintf and %s due to multiple pieces of data being needed.
     
    enephs, Mar 18, 2011 IP
  2. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    this has to do with a non binary file transfer in ftp, set your ftp client to binary and you should have the issue solved
     
    srisen2, Mar 18, 2011 IP
  3. enephs

    enephs Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    eh, I'm pretty confused by that. I looked around my ftp client on bluehost but i didn't see anything like that. Are you sure this has anything to do with ftp and not the mySQL database?
     
    enephs, Mar 18, 2011 IP
  4. dgreenhouse

    dgreenhouse Peon

    Messages:
    24
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    This might help, but of course I'm unsure...

    You mentioned that you have 400 Word (assume MS Word) documents.

    I see these "glaring gotchas" a lot these days and it's rather disconcerting to see them on "top level" sites. This might be an indication that MS Word and Microsoft are as ubiquitous as we were led to believe! :rolleyes: Content creators the world over must be using Word for their content creation and editing. Duh!!! :)

    The problem might stem from Word using what they term "Smart quotes" (which are just UNICODE) and your database and/or table collation is not set properly.

    The characters in question are:
    ‘ (U+2018) LEFT SINGLE QUOTATION MARK
    ’ (U+2019) RIGHT SINGLE QUOTATION MARK
    “ (U+201C) LEFT DOUBLE QUOTATION MARK
    ” (U+201D) RIGHT DOUBLE QUOTATION MARK

    If your database/table collation is not set correctly and you can't change it, you may need to convert these to straight quotes and apostrophes before inserting the data. Also look at add_slashes(), mysql_real_escape_string(), and the real_escape_string() method of the mysqli class if you're using that for your database operations.

    You might also want to check the value of magic_quotes_gpc in your php.ini file.

    First thoughts...
     
    dgreenhouse, Mar 18, 2011 IP
  5. Tanya Roberts

    Tanya Roberts Active Member

    Messages:
    250
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    #5
    In my opinion, the problem is with the encoding format. like UTF-8. see the table encoding type.
     
    Tanya Roberts, Mar 18, 2011 IP
  6. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    he is talking about the file itself not the table it happened to me before when i transfer my files via ftp, one way to try the binary method is to use a ftp client like filezilla try it on one file to test the results because i know that changing each variable is an amazing pain. I actually got a program to replace all occurrences of characters in files to fix mine at one point.
     
    srisen2, Mar 18, 2011 IP
  7. enephs

    enephs Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Nope. There is no file, unless your talking about the index file where I echo the article. I have an article which is stored in a row and column in a table on my mySQL database. I then call on this article to be echoed using a simple sprintf command using php. When it is displayed on the site, every " and ' is replaced with a �
     
    enephs, Mar 20, 2011 IP