Problems with UTF-8 charset and MySQL

Description

If you have UNICODE characters ie: È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß 00E0 à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü etc.....

BUT only get a "?" or black ?

You have to set all your charset to "utf-8" and make sure PHP and MySQL are ALSO set as such.

HOWEVER not all host have the charset correctly on MySQL CONNECTION! And you have to force it to. (cause you can't edit there server).

so in BOTH of your database.php file you have to change:

function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') {
global $$link;

if (USE_PCONNECT == 'true') {
$$link = mysql_pconnect($server, $username, $password);
} else {
$$link = mysql_connect($server, $username, $password);
}

if ($$link) mysql_select_db($database);

return $$link;
}

to:

function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') {
global $$link;

if (USE_PCONNECT == 'true') {
$$link = mysql_pconnect($server, $username, $password);
} else {
$$link = mysql_connect($server, $username, $password);
}

if ($$link) mysql_select_db($database);
// Lined added: Force DB connection charset to UTF8 for correct display/saving of unicode charaters
mysql_query("SET NAMES 'utf8'");
return $$link;
}

Fixed.... Possibly this added line could be added to language core.php files instead. All should actually be set to UTF-8 in core.php and all other files as well.

Environment

Platform: All

Steps to reproduce

None

Status

Assignee

Unassigned

Reporter

Jason

Labels

None

Severity

Minor

Components

Priority

Configure