how to save another language to mysql db using php
Posted: Fri Jul 22, 2011 12:23 pm
Hi
I am trying to add the data in Hindi from a html "text field" to mysql database using the php script.
It is not inserting the hindi text, it is inserting the English fonts.
Could anyone please help me to over come.
This is my html code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My Hindi Text Insertion</title>
</head>
<body>
<form action="submithindi.php">
F Name : <input type="text" name="txtfname" id="txtfname" style="font-family:'Kruti Dev 010'; font:'Kruti Dev 010'" />
L Name :<input type="text" name="txtlname" id="txtlname" style="font-family:'Kruti Dev 010'; font:'Kruti Dev 010'" />
<input type="submit" />
</form>
</body>
</html>
This is my PHP code snippet:
<?php
$con = mysql_connect("localhost","root","");
mysql_select_db("student", $con);
$fname = $_REQUEST["txtfname"];
$lname = $_REQUEST["txtlname"];
$query = mysql_query("insert into dlist(fname, lname) values('$fname', '$lname')") or die(mysql_error());
?>
Thi is smy MySql table structure: Please note that i followed the complete steps you have mentioned to create database & table.
fname char(20) utf8_general_ci Yes NULL
lname char(20) utf8_general_ci Yes NULL
Thanks & regards,
bhatnagar shikhar
I am trying to add the data in Hindi from a html "text field" to mysql database using the php script.
It is not inserting the hindi text, it is inserting the English fonts.
Could anyone please help me to over come.
This is my html code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My Hindi Text Insertion</title>
</head>
<body>
<form action="submithindi.php">
F Name : <input type="text" name="txtfname" id="txtfname" style="font-family:'Kruti Dev 010'; font:'Kruti Dev 010'" />
L Name :<input type="text" name="txtlname" id="txtlname" style="font-family:'Kruti Dev 010'; font:'Kruti Dev 010'" />
<input type="submit" />
</form>
</body>
</html>
This is my PHP code snippet:
<?php
$con = mysql_connect("localhost","root","");
mysql_select_db("student", $con);
$fname = $_REQUEST["txtfname"];
$lname = $_REQUEST["txtlname"];
$query = mysql_query("insert into dlist(fname, lname) values('$fname', '$lname')") or die(mysql_error());
?>
Thi is smy MySql table structure: Please note that i followed the complete steps you have mentioned to create database & table.
fname char(20) utf8_general_ci Yes NULL
lname char(20) utf8_general_ci Yes NULL
Thanks & regards,
bhatnagar shikhar