Recently I’m working on bangla. The part of this work I learn how to insert & retrieve bangla into MYSQL database using PHP.
Now I’ll discuss the whole process of insert & retrieve bangla into MYSQL database.
It is very easy, we all know how insert & retrieve data from database. Bangla font inserting is almost same. Only two queries are extra needed.
First we have created a database & table using MYSQL to insert bangla.
Now open the mysql command prompt & create database named bangla, & create a table named data.
Now write those command:
- mysql> set names ‘utf8′;
- mysql> create database bangla character set utf8 collate utf8_general_ci;
- mysql> use bangla;
- mysql> create table data (name varchar(100) character set utf8 collate utf8_general_ci);
Insert Bngla into database:
So we create database & table for where we insert bangla font. Now we have to create a simple form where we input bangla word.
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
</head>
<form method=”get” action=”bangla.php”>
insert bangla<input name=”name” type=”text” />
<br />
<br />
<input type=”submit” value=”insert bangla” />
</form>
<body>
</body>
</html>
Now just copy the code & save as banglainput.php.
Now insert bangla font into database.
<?php
$cnt = mysql_connect(“localhost”,”root”) or die (“could not localhost”);
mysql_select_db(‘bangla’,$cnt);
//********This Two Lines for bangla*********//
mysql_query(‘SET CHARACTER SET utf8′);mysql_query(“SET SESSION collation_connection =’utf8_general_ci’”) or die (mysql_error());
//*******************************************//
$sql = mysql_query(“insert into data values(‘$_GET[name]‘)”) or die(“error to creating row”);
$results = mysql_query(“select *from data”,$cnt);
echo “the results is “;
while($row = mysql_fetch_array($results))
{
echo $row['name'] .’ ‘;
}
?>
Now copy these code and save as bangle.php.
You must add these two lines just after selecting the database, i.e mysql_select_db() function.
mysql_query(’SET CHARACTER SET utf8′);
mysql_query(”SET SESSION collation_connection =’utf8_general_ci’”);
Its very easy Just Copy those code paste and run. Ooo the most importnt thing, you need a unicode for insert & retrive. i use avro unicode. So you must download avro unicode.
this tutorial is referenced by saidur vai.











14 comments
Comments feed for this article
May 20, 2008 at 6:06 pm
ranacse05
nice post buddy
May 28, 2008 at 5:53 pm
shamim
very good job…..
May 28, 2008 at 5:57 pm
Iqbal Hossain
Dear Saeed,
Thanks for this post, try to do more practice and more post.
Regards,
Iqbal Hossain
http://www.SabaSafa.com
August 10, 2008 at 5:41 am
Kushan Sasanka
Dear Friend,
Thank you very much for the script regarding utf8.
I didn’t try it for Bangla. I just tried for Sinhala.
Thats my language in sri lanka.
And the insert operation was successful.
Thank you very much.
keep it up… keep going…
Bye..
- Kushan –
from Sri Lanka
August 10, 2008 at 5:44 am
Kushan Sasanka
මම හොය හොයා හිටපු නියම ස්ක්රිප්ට් එක
September 5, 2008 at 6:47 am
Mr Zack
<?
if ($sub == “ok”) {
if (empty($name))
echo “Form is incomplete!”;
else {
$link=db_connect(“china”, $PHP_SELF);
mysql_query(‘SET CHARACTER SET utf8′);
mysql_query(“SET SESSION collation_connection=’utf8_general_ci’”);
$Sql = “INSERT INTO CloseOut (hotelname, hotel_id, closed_from, closed_to, reason, detail)
values (‘$_POST[name]‘,’$_POST[hotel_id]‘,’$_POST[date_from]‘,’$_POST[date_to]‘,’$_POST[reason]‘,’$_POST[detail]‘)”;
echo “$Sql”;
$result = mysql_query($Sql);
if (!$result)
echo “Error performing query!”;
else
echo “New package has been successfully added.”;
}
mysql_close($link);
}
?>
September 28, 2008 at 5:26 pm
saidur
OOPS ! quite similar with this post :
http://saidur.wordpress.com/2007/11/24/bangla-insert-and-retrive-using-php-mysql/
October 30, 2008 at 7:49 pm
Bayzed
Hi
November 16, 2008 at 12:32 pm
bopdilly
Excellent site! I wish the owner to develop and please all! http://sex-free-online.ru/map.html
November 25, 2008 at 7:04 am
proshanto
thank for ur kind cooperation.
i have ecuted these above codes. but i face the message “error to creating row”
wha can i do now.
November 25, 2008 at 7:17 am
Saeed
i think, you can not create database and table properly. to create database and table you need to follow those command
mysql> set names ‘utf8′;
mysql> create database bangla character set utf8 collate utf8_general_ci;
mysql> use bangla;
mysql> create table data (name varchar(100) character set utf8 collate utf8_general_ci);
if you follow those command properly then plz check you using variable name. correct your variable name with your own server configuretaion.
i think now you solve your problem.
thank you
November 25, 2008 at 7:48 am
proshanto
I am using
WampServer2.0c where MySQL5.0.51b, PHP 5.2.6, Apache 2.2.8.
My database name is psqlpro, table name is psqlpro1 and field name is p1. and there are many tables in my database.
I have two files named banglainput.php and bangla.php to insert and retrive bangla
the code of banglainput.php is
Untitled Document
insert bangla
and the code of bangla.php
Untitled Document
my ouput is “error to creating row”.
where is my problem? is there anyone to help me?
November 25, 2008 at 8:11 am
Saeed
there are everything is allright. donot panic. its very simple.
your problem solve is here
write those command in mysql:
mysql> set names ‘utf8′;
mysql> create database bangla character set utf8 collate utf8_general_ci;
mysql> use bangla;
mysql> create table data (name varchar(100) character set utf8 collate utf8_general_ci);
then paste my code to your IDE and run. i think it will be solve.
if yet not solve your problem then i invite you on yahoo. connact me asap.
i will solve it.
September 10, 2009 at 3:06 pm
sandrar
Hi! I was surfing and found your blog post… nice! I love your blog.
Cheers! Sandra. R.