Here's the situation: I have a dictionary database. I use special characters in the pronunciation (like this: 'hə.lə.ba.lu). However, when I use a PHP script to output this data, the special characters get replaced with question marks. Like this: 'h?.l?.ba.lu
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Newsletter Tests</title>
<style type="text/css">
#IPA
.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;
font-size:110%;
}
</style>
</head>
<body>
<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">
</fieldset>
</form><br />You entered: <strong><? echo $_POST['enteredWord'] ?><br /><br /></strong>
<?PHP
//Log in to database
$username="myusername";
$password="mypassword";
$database="mydatabase";
mysql_connect(localhost,$username,$password);
@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'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$Word=mysql_result($result,$i,"Word");
$Definition=mysql_result($result,$i,"Definition");
echo "<strong>$Word:</strong> $Definition<br />";
$i++;
}
Thanks for any pointers!