1

I have arabic font الاس٠in my db. It is fetching perfect arabic in some pages.

But it does not in another pages. why this differentiation?

I have put <meta charset="utf-8"> in both pages.

Any other things need to take care? Help me

Edit: Solved

condition0
  • 13
  • 4
  • Have you set the DB encoding as utf8? Have you set the DB handler as utf8? – chris85 Jan 09 '16 at 06:30
  • 1
    Possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – chris85 Jan 09 '16 at 06:31
  • @chris85: where the db handler can shown? – condition0 Jan 09 '16 at 06:53
  • I have Arabic displayed right in my Mysql database with PHPMyAdmin and displayed right in webpage. Provide more information about your database setup – A.Essam Jan 09 '16 at 09:45
  • Where you establish your database connection. – chris85 Jan 09 '16 at 16:59
  • @YehiaSedky: If my database shown arabic like yours it will display as question mark in `admin/page2.php` ,and `page1.php` will display perfectly. and vise versa...pls help me – condition0 Jan 10 '16 at 07:33
  • @chris85:this is my database `collation` of table field `name`- `varchar(100) utf8_general_ci` – condition0 Jan 10 '16 at 07:35
  • That is not the database connection. Show your PHP code that makes the connection to the database (with credentials removed). – chris85 Jan 10 '16 at 16:48
  • @condition0 show us your php code that inserts the data in your database and the code that retrieves it. A quick try is to insert query `SET NAMES 'utf8'` at the start of the connection and try to insert data again – A.Essam Jan 11 '16 at 07:36

2 Answers2

0

according to this:

The declaration should fit completely within the first 1024 bytes at the start of the file, so it's best to put it immediately after the opening head tag.

So it might be that you are placing the charset meta tag somewhere deep in your head, in a way that is does not appear in the first 1024 bytes loaded !

Try putting it directly after the head opening tag and see if that solves your problem !

Younes Regaieg
  • 4,156
  • 2
  • 21
  • 37
-1

use this function

mysql_query("SET NAMES 'utf8'");

or

$mysqli->set_charset("utf8");

for pdo ,your connection string like

"mysql:host=$host;dbname=$db;charset=utf8"
chris85
  • 23,846
  • 7
  • 34
  • 51
Rohullah Rajaee Rad
  • 571
  • 2
  • 9
  • 33