fredley
fredley

Reputation: 33851

UTF8 woes with mysql/php

I've got a mysql table with some imported data, in particular one value is Sinn Féin.

The character set used for my database is utf8_general_ci. The data displays fine in phpMyAdmin. In my site, I've used the PHP header header("Content-type: text/html; charset='utf-8'");. I've got <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> in my <head>.

My data still comes up as Sinn F�in. I've tried using utf8_decode, but that doesn't help. What am I doing wrong?

Upvotes: 1

Views: 219

Answers (2)

Alexmuz
Alexmuz

Reputation: 51

Аfter mysql_connect() add this line:

mysql_query ("SET NAMES utf8");

Upvotes: 1

Alireza
Alireza

Reputation: 6848

Try this:

$dbc="database connection";

mysql_query("SET NAMES utf8",$dbc);

Upvotes: 1

Related Questions