2

I have a PHP page where I am trying to display Arabic text but its showing.

In MySQL database I'm storing arabic text successfully.

I'm using the following code to connect to the database :

function connect(){
$this->dbLink = mysql_connect($this->dbHost,$this->dbUser,$this->dbPass);   
if(!$this->dbLink) die("Could not connect to database. " . mysql_error());
mysql_select_db($this->dbName);
mysql_set_charset("utf8", $this->dbLink); 
}

And using the following header in the PHP page :

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

But still no success.

Thanks for helping.

Paweł Dyda
  • 18,366
  • 7
  • 57
  • 79
air
  • 6,136
  • 26
  • 93
  • 125

6 Answers6

3

You can use this meta code:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

And please check mysql column's character type..

Look to this

Yusuf ali
  • 331
  • 1
  • 6
  • 15
  • i have same meata and column's character type is utf and collection is utf_general_ci and as i said, Arabic is saving properly in database. – air Aug 29 '11 at 20:40
  • shortly you hava problem ,when you select data? true? – Yusuf ali Aug 29 '11 at 20:48
3

check the file encoding, it should be UTF-8, and you can try to run the following query before querying the text:

mysql_query("SET NAMES UTF8");
Headshota
  • 21,021
  • 11
  • 61
  • 82
1

Addtional to the headers set in the meta section, check your default_charset setting in the php.ini. default_charset should be empty if you set content type header by your own or correspond with your content-type meta information.

1

You set a META-tag that tells the browser to use ISO-8859-1 (<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />), which is for latin-based scripts, but surely not Arabic.

Also make sure you have UTF-8 at all places:

  • the DB-column
  • the DB-connection (you already have it)
  • the website (via HTTP-header OR META-tag, you don't need both, and you don't need a second META-tag, as stated above…)
feeela
  • 29,399
  • 7
  • 59
  • 71
0

Try to add this two lines to your php script after the Mysql connection

mysql_query("SET NAMES cp1256"); mysql_query("set character set cp1256");

rhoula
  • 31
  • 2
0

Have you tried setting the connection to use UTF-8 (with mysql_set_charset)?

Mihai Nita
  • 5,547
  • 27
  • 27