0

I am using a magazine name listing program using php. Here I used to manipulate different languages.

I am inserting magazine name into a table. The field name is

 tbl_magazine  field type - varchar(32 collation utf8_general_ci

when I insert different languages into the table [using google translator]. This correctly inserted into my db [like this viewing in database সঙ্গে পরীক্ষা]. But when I retrieve this using php this record show as ????? like this.

If anyone know about this, please help me.

Jenz
  • 8,280
  • 7
  • 44
  • 77
deepu sankar
  • 4,335
  • 3
  • 26
  • 37
  • Can you show the code which retrieves it from database, and outputs it? Is your file encoded as utf-8? Also, is your webserver serving utf-8? – dkasipovic Mar 06 '14 at 10:55
  • 1
    See [UTF-8 all the way through](http://stackoverflow.com/a/279279). – eggyal Mar 06 '14 at 10:59
  • If you're sure database is dealing right with the text, you need to post the string in codes to examine what's happening. – Gustavo Mar 06 '14 at 21:26

4 Answers4

1

Try to use this code at top of your page,

mysql_query('SET character_set_results=utf8');

For more details, you can refer this tutorial, http://www.9lessons.info/2011/08/foreign-languages-using-mysql-and-php.html

Balaji Kandasamy
  • 4,446
  • 10
  • 40
  • 58
1

Set your database connection to UTF8:

mysql_query("SET CHARACTER SET UTF-8", $conn);
mysql_query("SET NAMES UTF-8", $conn);

Also ensure your HTTP responses are interpreted as UTF8:

header("Content-Type: text/html; charset=UTF-8");
0

first your db table must have utf8_general_ci collation

and place mysqli_set_charset ($con, "utf8"); after connection establish...

user1844933
  • 3,296
  • 2
  • 25
  • 42
0

Try executing the following query before you retrieve data:

SET NAMES utf8

It should help.

Eternal1
  • 5,447
  • 3
  • 30
  • 45