Get support with foreign and regional language in php and mysql | 2my4edge

28 August 2013

Get support with foreign and regional language in php and mysql

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.
support with foreign and regional language.


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. 

database table structure
In a collation the value taken as latin1_swedish-ci, we have to change that in the format of utf8_general_ci.

structure of table view

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 --- 
?>

and this support most of the languages. Thank you.

RELATED POSTS :











4 comments:

  1. nice post plz using mysqli bro

    ReplyDelete
  2. i need some help in thi stutorial. can au help me plz

    ReplyDelete

^