Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question
 
 
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. –  Fred -ii- Sep 30 '13 at 5:48
 
1  
Thank you so much. setting $con->set_charset("utf8"); solved my problem :) –  Laura Sep 30 '13 at 6:02
 
@Laura To properly close this question since it has been answered, see my answer then click the white checkmark till it turns green. Otherwise your question still remains in the unanswered category. –  Fred -ii- Oct 2 '13 at 14:01
show 1 more comment

2 Answers

After selecting database, add this:

mysql_query("set names 'utf8'");
share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.