MacMac
MacMac

Reputation: 35361

MySQL Collation or PHP side to display accented letters properly

What is the best Collation for the column that can allow to store accented letters and parse them out perfectly without any encoding error, because whenever I add an accented letter such as é, å, it shows out with an encoding problem on the PHP side, but in the MySQL side it's fine...

How do I get the accented letters display properly?

Upvotes: 2

Views: 2263

Answers (2)

wimvds
wimvds

Reputation: 12850

You get them correctly by matching the encoding on both ends, ie. both your PHP output and your DB should use the same encoding. For European languages I would suggest using UTF-8 for both your scripts and the DB. Just remember that you still have to initialize UTF-8 collation in MySQL using SET NAMES 'utf8' COLLATE 'utf8_general_ci' (so run this query just after you make a connection to the DB and you should be ok).

Upvotes: 2

Amber
Amber

Reputation: 527488

Perhaps your problem isn't within the database, but within however you're displaying things from PHP? What content encoding are you specifying in your output? You might need to manually send a header to specify that the content is UTF-8 if that's what you're trying to output.

For instance: header("Content-Type: text/html; charset=UTF-8");

Upvotes: 2

Related Questions