1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need to convert all database "bad characters" to UTF8

Discussion in 'PHP' started by trecords, Mar 28, 2012.

  1. #1
    Hi,

    I have multi database with 500+ tables. Some text is not correctly formatted as they are show this characters:
    É™lavÉ™ et which have to be: Əlavə et
    Ãœmumi which have to be: Ümumi

    So i need code for database or as php to convert such string into correct format, database collation is OK just need to convert in rows. I will make loop for all tables and row but I need correct code for to convert such strings into correct unicode.
     
    trecords, Mar 28, 2012 IP
  2. yho_o

    yho_o Well-Known Member

    Messages:
    353
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    #2
    try to export the mysql database, open the sql file with any editor, search for the 'encoding line' usually at the end of table creation query and like this
    ' ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'
    PHP:
    modify it to UTF8 if its not and import the data again

    hope its what you looking for

    Thanks
     
    yho_o, Mar 28, 2012 IP
  3. trecords

    trecords Well-Known Member

    Messages:
    145
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #3
    all of them are UTF8, I have tried to use CONVERT function but it work not for all databases. Is there are any other solution ?
     
    trecords, Mar 28, 2012 IP
  4. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    check out these:

    http://climbtothestars.org/archives/2004/07/18/converting-mysql-database-contents-to-utf-8/
    http://stackoverflow.com/questions/105572/a-script-to-change-all-tables-and-fields-to-the-utf-8-bin-collation-in-mysql
    http://forum.whmcs.com/showthread.php?t=21865
    Code (markup):
    Above all, be sure to make backups beforehand ;)
     
    szalinski, Apr 11, 2012 IP