SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Location
    Porto,Portugal
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Php/Mysql charset

    Hi i have a table in my mysql db with utf-8 charset but when i made a select in that table and display it in a php page the '', '' ... still appears wrong.

    In phpmyadmin in appears correct.

    What could be the problem?

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Are you also serving the webpage as UTF-8?

  3. #3
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you pass the value through htmlentities before displaying?

  4. #4
    SitePoint Zealot
    Join Date
    Dec 2008
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when connect to mysql in php execute following sql:
    SET NAMES utf8
    then encode your html page in utf8 encoding

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2009
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you should user UTF-8 encoding on your web page as well.that will solve your problem.
    I have recently had the same problem and when I used utf-8 on my web page it was working.
    In PHP also you will find some functions for encoding and decoding for the same purpose but I personally suggest you to use utf-8 on web page.

    Noddy

  6. #6
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Location
    Porto,Portugal
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am already using UTF-8 in my pages.
    The static texts working correctly. Only the dynamic data from mysql appears wrong.

    I will give a try to the SET Names function dispite i would prefer a simpler way of doing it.

    EDIT: i think is that i have created the db in latin1 instead of utf8. It seems it doesn´t work if i change the encoding later.
    I have created a new table in utf8 and it works.


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
  •