SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot clarnp49's Avatar
    Join Date
    Sep 2004
    Location
    Bowie MD
    Posts
    184
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Wacky Characters even with slashes

    I have content I am pulling from a database and just today I have run into a problem.
    It's browser independent but shows different characters for IE, Firefox.

    I get this �organic� when I output content. The ?diamonds are squares in IE. The code the echos this statement comes from here.
    e
    cho"<p class='c6'><a href='$file'>".$article_title."</a> - $description</p>";

    The red part is the section that is showing the weird characters.

    When the data is entered into the database it's run through a addslashes procedure and when it's pulled back out, it's run through a stripslashes procedure.

    Thanks.
    If it works don't fix it. If it's broke fix it.
    He who knows all is the smartest.
    He who doesn't know anything isn't dumbest.

  2. #2
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Character encoding of the string in the database is different to the one of the HTML document. You need to set a connection character set so that it converts correctly.

    Look for character sets in your database engine’s manual.

  3. #3
    SitePoint Zealot clarnp49's Avatar
    Join Date
    Sep 2004
    Location
    Bowie MD
    Posts
    184
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    This task looks ridiculous, in my page I have :
    <meta http-equiv="content-type" content="text/html; charset=utf-8">

    I have tried to change that table to UTF-8-BIN and that didn't work. I just got all these pages switched to be validated and now I come across this problem because I was told I needed a DOCTYPE and charset on the page to be proper HTML.

    Any other suggestions on this deal would be greatly appreciated and a direction to turn and learn how this whole thing works. So far, not impressed with the "proper" aspect of this. I never had a problem with this before.
    If it works don't fix it. If it's broke fix it.
    He who knows all is the smartest.
    He who doesn't know anything isn't dumbest.

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by clarnp49 View Post
    So far, not impressed with the "proper" aspect of this. I never had a problem with this before.
    That's because you've never done it 'proper' before.

    Just ensure all output meet the required encoding.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    SitePoint Zealot clarnp49's Avatar
    Join Date
    Sep 2004
    Location
    Bowie MD
    Posts
    184
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I understand that part, I'm really looking for help on it to get started? It's simple quotes so I don't understand how it couldn't be part of the UTF-8 standard.... unless I need to do something with the output to make it "UTF-8 able"...

    If you need more code please let me know. Thanks!

    And I meant I never had this problem until I changed the page to encode in UTF-8.
    If it works don't fix it. If it's broke fix it.
    He who knows all is the smartest.
    He who doesn't know anything isn't dumbest.


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
  •