SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict khuramyz's Avatar
    Join Date
    Oct 2005
    Location
    Manchester, UK
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A little help on htmlentities

    Hi,

    I had my site's data entry from some third party. They were having problems because of special characters like quotes, double quotes, pound simple etc.

    So I applied htmlentites($var, ENT_QUOTES) to all my data. That way, it is being sorted ok with everything turned into its subsequent HTML code and it looks Good.

    But it looks good in admin but doesnt show right on site on some places and shows things like ? question marks at places although the data looks clean.

    My site is for UK users, Do you think I should add something in my html head to make it recognize it better.
    I am using PHP 4 and MySQL5.
    The data shows right in admin edit forms as well as admin grid pages. It has something to do with my front end logic that I cant understand.

    I have included

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    in my front end html while i dont add it in the backend. Could this be a problem. Can I somehow tell my page that dude, these are special characters, Give them some respect.

    You know what i mean

    Regards

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Location
    Ballarat, Vic. Australia
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This will be something to do with character encoding. There is a good explanation of the problem here:

    http://www.ccs.uottawa.ca/webmaster/...haracters.html

    On that page they mention ensuring that your text is uniformly encoded. This can also happen at the database level. Chek the encoding or default encoding setting for your database. It may be that it is something other than iso-8859-1 or utf-8.

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,185
    Mentioned
    191 Post(s)
    Tagged
    2 Thread(s)

    question marks

    I don't think the issue is with htmlentities. Seeing question marks sounds more like a charater encoding issue. Do your pages have
    HTML Code:
    <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
    or something else that's appropriate? Are they being served using the same character encoding as the meta?

  4. #4
    SitePoint Addict khuramyz's Avatar
    Join Date
    Oct 2005
    Location
    Manchester, UK
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ummm I am already using the UTF-8 encoding. Still the problem occurs on some pages.
    I guess the problem was that while saving, I was doing htmlentities and while retrieving i was using htmlspecialchars. silly me.
    I think, after using htmlentites with all its force, you dont need htmlspecialchars.
    Please correct me if i am wrong.

    Thank you all the same fellas


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
  •