Getting special characters out of a MySQL database with PHP -


this question has answer here:

i have table includes special characters such ™.

this character can entered , viewed using phpmyadmin , other software, when use select statement in php output browser, diamond question mark in it.

the table type myisam. encoding utf-8 unicode. collation utf8_unicode_ci.

the first line of html head is

<meta http-equiv="content-type" content="text/html; charset=utf-8"> 

i tried using htmlentities() function on string before outputting it. no luck.

i tried adding php before output (no difference):

header('content-type: text/html; charset=utf-8'); 

lastly tried adding right below initial mysql connection (this resulted in additional odd characters being displayed):

$db_charset = mysql_set_charset('utf8',$db); 

what have missed?

below code works me.

$sql = "select * chartest"; mysql_set_charset("utf8"); $rs = mysql_query($sql); header('content-type: text/html; charset=utf-8'); while ($row = mysql_fetch_array($rs)) {     echo $row['name']; } 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -