SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2008
    0 Post(s)
    0 Thread(s)

    UTF-8 and umlauts saving in DB?

    Hi everybody,

    my first post here on sitepoint

    My Debian server is all UTF-8, i mean i hobe so, cause im not sure if everything is ok.

    How the umlauts have to appear in the db (phpmyadmin)?
    They all look ok in the browser.

    But in the db on some places they are like
    and in other places in decimal
    PHP Code:

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2007
    0 Post(s)
    0 Thread(s)
    It depends on how you are interacting with the database I believe. I'm no expert, but I had to work with this issue for a while since I use asian scripts on my site.

    Make sure that in phpMyAdmin that you have the right collation and settings for the database before you begin. utf8 / utf8_general_ci or whatever they are is what I used.

    But you also need to be sure that you are interacting with the database using utf8 so that they match up. For example, if you interact using PHP and mysql_query, then by default it uses latin encodings I believe.

    If PHP, connect to the database...

    $connection = mysql_connect(...)

    and after connected

    PHP Code:
    mysql_query("SET CHARACTER SET 'utf8'"$connection)
            or die(
    "Could not set character set to utf-8");
    mysql_query("SET NAMES 'utf8'"$connection)
            or die(
    "Could not set names to utf-8"); 
    Now, any queries done via PHP will be done with the utf8 encoding, and the database is storing as utf8 as well. With the result, everything should work out alright and you should also be able to read the characters in the database through phpMyAdmin


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts