blub
blub

Reputation: 2166

Strange characters in mysql dbase

When I type strange characters like é or ë and store it in a mysql dbase; the character will be converted to: é

It probably will have to do something with my character set. But i don't now where to start. On top of the page i inserted:

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

The collocation of the field in the dbase is: utf8_unicode_ci

Displaying the field in a webpage results in é and ë but displaying them in a textarea results in é

How can i change this?

Upvotes: 2

Views: 7987

Answers (3)

Nico
Nico

Reputation:

the mysql_query string works well! :)

to avoid aby encoding problems just set:

  • meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
  • utf-8-general-ci on ALL char/text fields of any mysql table you use
  • mysql_query("set names 'utf8'"); right after th database connection call

Upvotes: 1

random
random

Reputation: 9955

Make sure the collation for the columns, tables and the database are all set to utf8_unicode_ci or utf8_general_ci

You also have to keep in mind, in addition to the meta directive that you already have, to extract and insert entries to and from the database in the same encoding.

Include this line right after you've made the call to connect to the database:

mysql_query("set names 'utf8'");

This will keep the character set properly as UTF-8 state as you manipulate and extract entries in the database.

If you can for next time, have everything in UTF-8 from the very start.

Upvotes: 2

c_harm
c_harm

Reputation:

There are a two things you can do:

Upvotes: 2

Related Questions