Here's the situation: I have a dictionary database. I use special characters in the pronunciation (like this: 'hə.lə However, when I use a PHP script to output this data, the special characters get replaced with question marks. Like this: 'h?.l?

I've read a lot on this topic, but I'm not sure where to start or what to check.

Here's some information:

The collation of my database is utf8_general_ci
The collation of the tables is utf8_general_ci
The character set of the page is UTF-8

I've also seen some references to htmlentities, but I'm not sure how to incorporate the code into my code.

Here is the PHP code that I'm using for the page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Newsletter Tests</title>
<style type="text/css">
.IPA {
font-family:Arial Unicode MS,Code2000,Gentium,GentiumAlt,DejaVu Sans,Segoe UI,Lucida Grande,Charis SIL,Doulos SIL,TITUS Cyberbit Basic,Lucida Sans Unicode,sans-serif;
<form name="word" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"><fieldset>
<legend>Type your word here:</legend>
  <input type="text" name="enteredWord" id="wotd" size="77"> <input type="submit" name="Submit" value="Submit" id="submitwotd">
</form><br />You entered: <strong><? echo $_POST['enteredWord'] ?><br /><br /></strong>

//Log in to database
@mysql_select_db($database) or die( "Unable to select database");

//declare the variable POSTED from the form
$enteredWord = $_POST['enteredWord'];

//if $enteredWord is not blank then proceed.
if ($enteredWord != '') {

$query="SELECT * FROM Dictionary WHERE word='$enteredWord'";



  while ($i < $num) {


  echo "<strong>$Word:</strong> $Definition<br />";


Thanks for any pointers!

Recommended Answers

All 3 Replies

try some different charset for HTML.

<meta http-equiv="Content-Type" content="text/html; charset=ISO 8859-1" />

Thanks for the suggestion. I tried that, but it didn't work--same problem. I get question marks again.

Posting in case it helps anyone:

I think I figured it out. First, my problem was that I was copying and pasting special characters into PHPMyAdmin. I decided to try decoding the special characters first. So ə became &#601;. After I did that, I used this code:

<? echo htmlspecialchars($my_db_field, ENT_QUOTES, "UTF-8", false); ?>

to generate the output the way I wanted.

Now, I just need to figure out how to convert all the special characters to decoded HTML.

What a beginner I am... :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.