2

I have a page with forms to add or edit a entry to a mysql-database. Everything works fine, the form shows everything right, the output on the page is right.

Only when I open the mysql-database (phpMyAdmin) the entries are shown wrong. Some german letters are wrong.

For example André instead of André. Or groß instead of groß.

The Output on the page works fine. Also the edit-function in an HTML-form works fine. I just don't understand why everything is written wrong in the database.

All my PHP-Page are in "utf-8".

Francisco
  • 10,918
  • 6
  • 34
  • 45
  • mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'"); – tony gil Feb 14 '18 at 13:50

2 Answers2

0

Access this link:

http://dev.mysql.com/doc/refman/5.0/en/charset-applications.html

When you create a database, you can set CHARACTER SET by utf8.

Example:

  CREATE DATABASE tablename 
  DEFAULT CHARACTER SET utf8
  DEFAULT COLLATE utf8_general_ci;

Make sure your database has UTF8 char set as well

You can convert you existing table like this:

ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
bcesars
  • 1,016
  • 1
  • 17
  • 36
0

Add Header to the top of your php code. This will set encoding of content.

header('Content-Type: text/html; charset=utf-8');

You can use any encoding, which is set in your database instead ofutf-8.

Vitalii
  • 1,137
  • 14
  • 25