SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Special characters & doctypes

    Hi Guys,

    I have the following characters stored in a db;

    HTML Code:
    $
    
    
    $
    
    However, when I pull them from the database and display them on a page, I get a weird character show in place of the , $ and . However, this works fine on another server.

    I originally thought this could be a problem with the doctype. I am using utf-8, but still get the same problem.

    Any ideas?

  2. #2
    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)
    How are you determining that they work fine on one server, but not the next? Are you using the same php application, desktop application...

    There a few things this could be, but lets narrow down the options huh?

    Have you tried htmlspecialchars()?
    @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.

  3. #3
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SilverBulletUK View Post
    How are you determining that they work fine on one server, but not the next? Are you using the same php application, desktop application...

    There a few things this could be, but lets narrow down the options huh?
    I am using exactly the same php application, MySQL database and structure. The browser I am viewing with is also the same.

    Weird huh?

  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)
    As this works fine on one server, and not the other whilst everything else is the same - logic dictates the server is the issue.

    Have you compared the headers sent by the servers? I'd bet a lemon-top ice cream that they are different.

    The LiveHTTPHeaders extension with Firebox is usually my preferred method.
    @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 Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SilverBulletUK View Post
    As this works fine on one server, and not the other whilst everything else is the same - logic dictates the server is the issue.

    Have you compared the headers sent by the servers? I'd bet a lemon-top ice cream that they are different.

    The LiveHTTPHeaders extension with Firebox is usually my preferred method.
    I will check, thanks

  6. #6
    SitePoint Addict
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can check the headers that the web server is sending by going to View > Character Encoding in FireFox. For example, this site is using ISO-8859-1.

    The problem is that the page char encoding and the server's header's can be different. And the server will "win".

    This PHP header should take care of it
    header( "Content-Type: text/html; charset=utf-8" );


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
  •