2

I have done a code in PHP to insert data into MySql in malayalam. When I insert data, It becomes English in database.. I have set charset to utf-8 in my code and in data base utf8 general_ci..please anyone give answer..thanks in advance

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
user3171771
  • 39
  • 1
  • 3

3 Answers3

1

You can give this simple code

SELECT * FROM dictionary WHERE malayalam = 'ആകാശം'

This code will work fine in phpmysql,also you can refer this link

Press this link for your clarification

Community
  • 1
  • 1
KesaVan
  • 1,031
  • 16
  • 32
1

1) Add the code beginning of the php page <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

2) Make sure your database & tables are on Collation utf8_general_ci

3) Use the database connection code: $conn = new mysqli($server, $user, $password, $database); $conn->set_charset("utf8");

4) Then try insert query and retrieve query using $conn handler, ie: $q_newspage="SELECT * FROM news GROUP BY id DESC LIMIT 8"; $qresult_newspage=$conn->query("$q_newspage");

Thanks

Niyas
  • 11
  • 1
  • thanks for mentioning collation : we generally don't set this and it becomes the swedish one by default. – Nikhil VJ Aug 23 '19 at 02:21
0

Don't forget to set charset as utf8 in META tag

<meta charset="utf-8">

For More

And in mysql as

mysql_set_charset('utf8');

Then you can insert in to db as,

INSERT INTO tableName (name) VALUES ('രാകേഷ്');
Rakesh KR
  • 6,357
  • 5
  • 40
  • 55