Php page does not display arabic text

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

In the MySQL database, I successfully save the Arabic text.

I use 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 heading on a PHP page:

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

But there is still no success.

Thanks for the help.

+1
php internationalization character-encoding
source share
6 answers

You can use this meta code:

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

And please check mysql column character type ..

Look this

+3
source share

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

 mysql_query("SET NAMES UTF8"); 
+2
source share

When adding to the headers indicated in the meta section, check the default_charset setting in php.ini. default_charset should be empty if you set the title of the content type as you wish or match the meta-information of your content.

+1
source share

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 scripts, but definitely not arabic.

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

  • DB-column
  • DB connection (you already have)
  • website (via the HTTP header OR META tag, you do not need both, and you do not need the second META tag, as mentioned above ...)
+1
source share

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

0
source share

Try adding these two lines to your php script after connecting mysql

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

0
source share

All Articles