0

I want to transfer my database to another server, I found that my utf-8 characters are not display correctly in my database, they are displaying like this: enter image description here

I use persian language. I exported my database and used notepad++ to convert them but it didn't work. previously I did this convert using notepad++ on my subtitles srt files and it worked well.

ex: exporting : علیرضا in old & new phpmyadmin (both) displays like : احمدي

I also tried to change collation to utf8_persian_ci.

Alireza Sabahi
  • 647
  • 1
  • 12
  • 35
  • There should be no need to convert anything. You export it using the correct encoding from your old database and import it using the correct encoding into your new database. We need more details what else you're doing here to be able to help you. – deceze Apr 07 '17 at 12:20
  • just think I want to show these characters correctly in my .txt file (احمدي) in Persian. – Alireza Sabahi Apr 07 '17 at 12:24
  • You might want to start here: [What Every Programmer Absolutely, Positively Needs To Know About Encodings And Character Sets To Work With Text](http://kunststube.net/encoding/) – deceze Apr 07 '17 at 12:27
  • thank you, but it does't help me. – Alireza Sabahi Apr 07 '17 at 12:32
  • See "Mojibake" in [_this_](http://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored). – Rick James Apr 08 '17 at 05:33

2 Answers2

1

I faced this problem earlier while I was creating the record in some other language (other than English) and I tried this code:

//Connect to database
//setting character set
mysql_set_charset('utf8'); // This is important
//Now INSERT Query
$sql = "INSERT INTO ...";
$res = mysql_query($sql);

and In phpMyAdmin, I selected this Collation

enter image description here

It worked for me.

I hope this will help.

Arpit Kumar
  • 2,179
  • 5
  • 28
  • 53
0

Open your sql file in notepad++, then just change encoding from utf-8 to ansi and save it, after opening the file in notepad++ or uploading in database everything will be allright.

Alireza Sabahi
  • 647
  • 1
  • 12
  • 35