scarhand
scarhand

Reputation: 4337

database not storing accented characters properly

pretty simple really, i've set all collations to utf8_general_ci, and yet, the database does not seem to be storing accented characters properly

for example, it is storing "Québec" as "Québec"

now before the variable is inserted, it goes through the following function:

function dbprep ($v)
{
    $v = html_entity_decode($v, ENT_QUOTES);
    $v = htmlspecialchars_decode($v, ENT_QUOTES);
    $v = strip_tags($v);
    $v = trim($v);
    $v = mysql_real_escape_string($v);

    return $v;
}

also, i should mention that i use the following meta tag in my html:

<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>

why is it not storing the values properly? it makes no sense to me.

Upvotes: 0

Views: 1302

Answers (2)

scarhand
scarhand

Reputation: 4337

Using mysql_query("SET NAMES utf8") after mysql_connect() worked.

Upvotes: 0

Kris
Kris

Reputation: 2128

Try executing this query first:

SET CHARACTER SET utf8

Upvotes: 1

Related Questions