-1

I apologize if this is a duplicate question. I am a newbie to special characters and know very little about special character encoding and decoding. I looked all over stackoverflow, tried the solutions but still cannot solve my problem. I have stored special characters in my mysql database, like prēməˈCHo͝or/,/-ˈt(y)o͝or. Database collation is utf8_bin. It shows fine in my database field but on my page, it displays as ?pr?m??CHo?or/,/-?t(y)o?or. I have added the following line to display this field:

<?php 
echo strip_tags(html_entity_decode($row->Phonetic_eng,ENT_QUOTES, "UTF-8")); 
?>

I have also added this to the php file:

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

Kindly note that saving to database is not the issue I think. It is displaying the data that is the problem I think. In that case, how should I write the display statement:

<?php 
echo strip_tags(html_entity_decode($row->Phonetic_eng,ENT_QUOTES, "UTF-8")); 
?>

I would really appreciate any help. Thank you in advance

undone
  • 7,857
  • 4
  • 44
  • 69
Laura
  • 27
  • 2
  • 6
  • possible duplicate of: http://stackoverflow.com/questions/15892610/getting-special-characters-out-of-a-mysql-database-with-php http://stackoverflow.com/questions/12873953/retrieving-special-characters-from-mysql-database-php –  Sep 30 '13 at 05:33
  • Assuming you're using MySQLi and something to the affect of `$con=mysqli_connect("xxx","xxx","xxx","xxx");` use `$con->set_charset("utf8");` just above your queries. This works well for me. – Funk Forty Niner Sep 30 '13 at 05:48
  • possible duplicate of [UTF-8 all the way through my web application (Apache, MySQL, PHP, ...)](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through-my-web-application-apache-mysql-php) – deceze Sep 30 '13 at 06:02
  • 1
    Thank you so much. setting $con->set_charset("utf8"); solved my problem :) – Laura Sep 30 '13 at 06:02
  • @Laura To properly close this question since it has been answered, [see my answer](http://stackoverflow.com/a/19094146/1415724) then click the white checkmark till it turns green. Otherwise your question still remains in the unanswered category. – Funk Forty Niner Oct 02 '13 at 14:01
  • @Laura You haven't accepted my answer. Click the checkmark so we can close this question properly. – Funk Forty Niner Oct 05 '13 at 14:34

2 Answers2

4

Assuming you're using MySQLi and something to the affect of:

$con=mysqli_connect("xxx","xxx","xxx","xxx"); 

use $con->set_charset("utf8"); just above your queries.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
0

After selecting database, add this:

mysql_query("set names 'utf8'");
undone
  • 7,857
  • 4
  • 44
  • 69