Page 1 of 1

PHP, MySQL and Arabic

Posted: Thu Mar 08, 2007 7:09 am
by ntbd
Hiya,

Im building a website for a photographer with fans speaking three rather different languages, English, French and Arabic.

I can not for the life of me get the Arabic to display! It shows fine in MySQLmyAdmin and if I hardcode the Arabic into the HTML it displays properly, but I can't retrieve it from the database.

Heres a sample page:

Code: Select all

<?PHP
mysql_connect('localhost','*********','*********');
mysql_select_db('nour_nour');

setlocale(LC_ALL, 'ar_AR');
header('Content-Type: text/html; charset=UTF-8'); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<title>Language test</title>
</head>
<body>
<?PHP
	$t = mysql_query("SELECT * FROM translations WHERE name = 'website tagline' LIMIT 1");
	echo "English: " . mysql_result($t,0,"english")."<br />";
	echo "Français: " . mysql_result($t,0,"french")."<br />";
	echo "??????? " . mysql_result($t,0,"arabic")."<br />";
	
	echo mysql_error();
?>
The ????? there is hard-coded arabic, just to prove the page is displaying in the browser.
The whole database has been set to UT8-Unicode and yet the Arabic just WILL**NOT**DISPLAY.

Its driving me nuts!

Posted: Thu Mar 08, 2007 7:13 am
by ntbd
Just for the record - heres what that outputs in Safari:
Image

Posted: Thu Mar 08, 2007 8:11 am
by infolock
http://www.phpclasses.org/browse/package/2875.html might help you out.

I looked at php.net's supported languages and did not find arabic.

You may want to search mysql though and see if arabic is supported by default, or if you must install a language pack for it.

Otherwise, the above class says it works. i didn't try it, but it might be worth a shot for you to try...


Edit: Even better, you may want to check out this url: http://www.al-shamaa.com/php/arabic/

It's a project specifically dedicated to Arabic-based applications.