hello and thanks in advance for any help provided.
I am about to start developing a website that will require 5 different languages. To test language support, I have created a mysql table with 2 fields.. 'langID' & 'text'.
The table is very simple and only has 5 rows. The first field has the name of the language and the second field has a paragraph or so of random text in the specified language. Both Feilds have the collation set to "utf8_unicode_ci".
I used phpmyadmin to create the table and populate it. From within phpmyadmin I can see the text fields in the correct language and everything is fine. also from within phpmyadmin i can click a link and the full table is outputted into an html page (obviously generated using php). This page is also fine. All the languages display correctly.
My problem is when I create a page to extract the data and display it myself. Arabic and Japanese do not show at all (i only get "?" instead of characters) and the spanish and german languages also do not display correctly (tiny question marks for certain characters).
I'm not sure where to go from here.. I have read a lot about the mbString functionality of php and got nowhere. Also looked at the GetText functions but that seems to be over the top.
How can phpmyadmin display the languages correctly (print view) but i can't do the same with my code?
my code is as follows, very simple:
<!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" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Language Test Page</title>
</head>
<body>
<?php
// database connect information
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "test";
// Connect to MySql
$connect = mysql_connect($dbhost, $dbuser, $dbpass)
or die("Unable to connect to MySql : mysql_error()");
// Connect to Database
$db = mysql_select_db($dbname, $connect)
or die("Unable to connect to Database : mysql_error()");
// SQL to retreive Data
$sql = "SELECT * FROM lang";
$result = mysql_query($sql)
or die("unable to retrieve data:" . mysql_error());
while ($row = mysql_fetch_array($result)) {
$lang = $row["langID"];
$text = $row["text"];
print ("<b>".$lang."</b><br>".$text."<br><br><br>");
}
?>
</body>
</html>
Please help. I'm getting as frustrated as a postal worker here...