silent_coder14
silent_coder14

Reputation: 583

How to properly save non english character into MySQL database using PHP?

I am working on parsing a HTML of website and saving information to database but in the website, there are Non English character (like Chinese, Indian, Korean, etc) that should be saved into MySQL. My problem is that in MySQL (when i view those information using PHP MyAdmin), it displays weird characters.

İlginç Gerçekler
ê³µì—°ì •ë³´ PARTI(ì—°ê·¹,콘서트,뮤지컬,오í...
ì •ì‹ ì—°ë ¹ 테스트

How to properly save these information to database?

Upvotes: 0

Views: 2316

Answers (4)

Alireza
Alireza

Reputation: 1438

change your table collation to utf8

$con=mysql_connect("hostname","username","password");

mysql_query("SET CHARACTER SET utf8",$con);

check also this post

Upvotes: 0

koala12
koala12

Reputation: 66

try using

mysql_query("SET NAMES 'UTF8'");

after mysql_connect or mysql_select_db. I use that for Turkish mysql_query("SET NAMES 'latin5'");

Upvotes: 5

elvenbyte
elvenbyte

Reputation: 776

You must convert your insertion and/or tables to another coding style. Here you are how: http://dev.mysql.com/doc/refman/5.0/en/charset-convert.html

Upvotes: 0

Rosmarine Popcorn
Rosmarine Popcorn

Reputation: 10967

First of all make sure that the Table and Row Encoding is UTF-8 Formated. Next you should save the PHP Script file as UTF-8 Encoded With or Without BOM.

Or you can try using htmlspecialchars(); function to do that.

Upvotes: 0

Related Questions