-2

I am using MySQL 5.5 version

when i try to insert the ‘ special character in database it is automatically converted into ’ .

i changed the database character set to utf8 & character_set_connection to utf8 but i unable to get the expected result.

how to solve this issue ?

kindly help on this

SiKum
  • 95
  • 3
  • 6

2 Answers2

0

You need to check how you are sending the data. If the character set in the database is utf-8, you need to send like that to.

Try to encode the data before, like that:

$sql = "INSERT INTO tablex(field) VALUES('".utf8_encode($mydata)."')";
rcmonteiro
  • 76
  • 1
  • 8
-2

It is important to make sure that every part of your connection is using utf8, otherwise you will run into problems.

Below we will create a utf8 connection to the database, perform set names which is vitally important and then write using a utf8_encode method.

mysql_connect("host", "user", "pass");
mysql_query("SET character_set_results=utf8");
mysql_set_charset('utf8');
mb_internal_encoding('UTF-8');
mysql_select_db("my_db");
mysql_query("set names 'utf8'");

$sql = "INSERT INTO `table`(`foo`) VALUES('".utf8_encode($bar)."')";
AO_
  • 2,573
  • 3
  • 30
  • 31