3

I had a mysql database in which I saved some special characters é , but in the database it was saved like this é, later on I realised that it is due to the encoding and I changed the encoding scheme for my table and DB to UTF-8 but the text already inserted in it didn't changed,

My question is

  • Is there a way to automatically change all the content to 'obey' UTF-8 .
  • Is there a way that I can alteast update é to é?

NOTE: I know about the update command , but I dont think that will help here with characters with in the field.

PHPLove
  • 65
  • 6
  • @KirenSiva the problem is with existing data, the question you are referring is telling when the user wants to create a new DB – PHPLove Jan 02 '15 at 09:34
  • 1
    Check the encoding for the individual columns, altering a table does not automatically convert the character set of the columns contained in the table, just like altering the charset of the DB does not convert the tables. – deacs Jan 02 '15 at 09:37
  • Found something [here](https://docs.moodle.org/23/en/Converting_your_MySQL_database_to_UTF8) from Moodle documentation which sounds like the correct procedure for your case. – Tensibai Jan 02 '15 at 09:57
  • Check [this thread][1] - more about utf8, conversions etc. [1]: http://stackoverflow.com/questions/2159434/set-names-utf8-in-mysql – Mikrobi Jan 02 '15 at 10:22

1 Answers1

0

I had some similar problems.

You need to set the encoding to utf-8 in:

  • the html or php file
  • the database column
  • and the database connection

From what you have said you already set the encoding in the database column.

To change the database connection use mysqli_set_charset ($conn, 'UTF-8');

If all of these are set to UTF-8 the data should display correctly.

  • @SmartMindx I think you should be fine by setting the three parts to UTF-8. The times I've tried it it worked. Let me know if you have a problem though and I'll try to help you.. :) –  Jan 02 '15 at 10:10
  • 1
    my only prblem is wirth the existing data inside the db, I want to change that data – PHPLove Jan 02 '15 at 10:41
  • @SmartMindx Run the following SQL command for all your tables: `ALTER TABLE mytable CONVERT TO CHARACTER SET utf8` –  Jan 02 '15 at 10:43