SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    UTF-8 causing trouble :(

    Hi everyone,

    I need some help with the following issue :
    The accentuated characters of the content taken form the UTF-8 database gets garbled once displayed on my website.

    What I don't understand is that everything seems to be properly set :

    my.ini
    Code:
    [mysql]
    default-character-set = utf8
    default-character-set = utf8
    character-set-server = utf8
    collation-server = utf8_general_ci
    init_connect = 'SET collation_connection = utf8_general_ci'
    init_connect = 'SET NAMES utf8'
    PHP header
    Code:
    header("Content-Type:text/html; charset=utf-8");
    Metas
    Code:
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    Table structure
    Code:
    CREATE TABLE `mod_geonames` (
      `geoname_id` mediumint(9) NOT NULL,
      `name` varchar(200) default NULL,
      `latitude` decimal(10,7) default NULL,
      `longitude` decimal(10,7) default NULL,
      `country_code` varchar(2) default NULL,
      PRIMARY KEY  (`geoname_id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
    So, what else could cause the problem?
    I am at a total loss of ideas after extensive googling

    Thanks for the help!
    Last edited by sleidia; Feb 28, 2009 at 11:16.

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Out of desperation, I've tried one other thing :
    I made a sql dump of the database and then pasted it in a UTF-8 sql file on pspad, then saved it and imported it again into the database. The result was that everything was displayed properly in the website this time ... but all is garbled when viewing the data in SQLyog

    Note that I'm working locally on appserv/windows vista.

    Any help will be highly appreciated

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, some great guy on a different forum gave the solution.

    Actually, I just had to insert
    mysql_query("SET NAMES 'UTF8'");
    just after the connexion to the database in the PHP code.

    I hope it will help others.


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
  •