Usually you may know or don’t know, in a PhpMyadmin default setting does not support the foreign and regional language. It default supporting language is English. I’m from India, so here most of them using so many languages. So today I’m going to show you that how to insert the foreign and regional language in mysql database using php.

The above image is the snap of what is present in the database. In a usual insert the foreign and other language is does not support. That will be inserted as like ?????????????? (question marks ) or some other thing like not readable. So let see how to solve that. I’m from india, tamilnadu. My mother tongue is tamil so I’m going to insert tamil in database.
HTML META TAG
Html meta tag must in the character set of UTF-8.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
SAMPLE DATABASE STRUCTURE
Database name --> 2my4edge
Table name -->comment
Column names --> id, msg, ip_add
and the character set should be UTF-8 format.
while creating database table, you should follow the below step.
and it is a small implementation of insert in database. Previous tutorial ajax insert and view.
In a collation the value taken as latin1_swedish-ci, we have to change that in the format of utf8_general_ci.
INSERT CODE
While writing insert code we have to add the prefix as N. N is stands for national regional language character set.
mysql_query("INSERT INTO `comment`(msg,ip_add) values
(N'$content',N'$ip')");
FETCH CODE
While fetching from database we have to add the character set type in php.
<?php
include('db.php');
mysql_query ("set character_set_results='utf8'");
---- fetching code ---
?>
include('db.php');
mysql_query ("set character_set_results='utf8'");
---- fetching code ---
?>
and this support most of the languages. Thank you.
RELATED POSTS :
nice post plz using mysqli bro
ReplyDeletenice post guru keep it up
ReplyDeletenice post guruji keep it up
ReplyDeletei need some help in thi stutorial. can au help me plz
ReplyDelete