{"id":38,"date":"2006-04-26T09:42:00","date_gmt":"2006-04-26T08:42:00","guid":{"rendered":"https:\/\/www.dont-panic.cc\/capi\/archives\/38"},"modified":"2006-04-26T09:42:28","modified_gmt":"2006-04-26T08:42:28","slug":"gentoo-mysql-and-php-charset-problems","status":"publish","type":"post","link":"https:\/\/www.dont-panic.cc\/capi\/2006\/04\/26\/gentoo-mysql-and-php-charset-problems\/","title":{"rendered":"Gentoo: MySQL and PHP Charset Problems"},"content":{"rendered":"<p>At the moment, <a href=\"http:\/\/www.gentoo.org\">Gentoo<\/a> is experiencing several inconsistency and problems with character sets between <a href=\"http:\/\/www.mysql.com\">MySQL<\/a> and <a href=\"http:\/\/www.php.net\">PHP<\/a>. This is primarely based on MySQL-4.1 now updating from 4.0 without warning and user interaction which most of the times breaks existing extended characters as MySQL now stores every dump from former databases as UTF-8, which is still badly supported by PHP.<\/p>\n<p>For many PHP web applications which experience problems with extended characters (like umlauts, accents, &#8230;), the following hack might help.<\/p>\n<ol>\n<li>Locate the file where the mysql database connection is opened.<\/li>\n<li>Add the following commands after opening the database connection:<br \/>\n<code> mysql_query('SET character_set_client=latin1');<br \/>\nmysql_query('SET character_set_results=latin1');<br \/>\nmysql_query('SET character_set_connection=latin1');<\/code><\/li>\n<\/ol>\n<p>This will resume using latin1 instead of UTF-8 for the connection and the result set. For performance reasons, the data in the database should then be stored as latin1 as well.<\/p>\n<p>According to <a href=\"http:\/\/forums.gentoo.org\/viewtopic-t-436439-postdays-0-postorder-asc-start-50.html\">messages<\/a> in the Gentoo Forum, the developers have now released an ebuild for PHP (both 5.x and 4.4.2) that will regard character-set settings in my.cnf in a section especially for php (still in unstable). You should use the section [php-cli], [php-cgi] and\/or [php-apache2handler]. Unfortunately I have not yet had time to test this out.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At the moment, Gentoo is experiencing several inconsistency and problems with character sets between MySQL and PHP. This is primarely based on MySQL-4.1 now updating from 4.0 without warning and user interaction which most of the times breaks existing extended characters as MySQL now stores every dump from former databases as UTF-8, which is still &hellip; <a href=\"https:\/\/www.dont-panic.cc\/capi\/2006\/04\/26\/gentoo-mysql-and-php-charset-problems\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Gentoo: MySQL and PHP Charset Problems&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,10],"tags":[],"class_list":["post-38","post","type-post","status-publish","format-standard","hentry","category-internet","category-sysadmin"],"_links":{"self":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":0,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dont-panic.cc\/capi\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}