Jump to content

help in convert encoding to utf-8


nasser bahaj

Recommended Posts

hi guys

 

please i need  your help in this problem.

 

i have vbulliten forum installed on my website (in arabic language).

 

and i have a php page , i want this php page show a thread title from the forum when i send thread id via GET method

for example :

 

http://www.mysite.com/page.php?t=55

 

i included config file of vbulliten and connected to database and got the title of thread successfully.

 

but the problem is encoding. the language appear unreadable

 

I tried to convert it to utf-8 (via mb_convert_encoding function) but the language still appear like this :

 

ãÈÊÏÁ Úãá äÌã ÈÏÇÎáÉ áãÚÉ

 

thank you all

 

best regards

 

 

Link to comment
https://forums.phpfreaks.com/topic/198326-help-in-convert-encoding-to-utf-8/
Share on other sites

Make sure the document itself is saved in UTF-8. When you save documents, they are saved in various encodings - but not all editors will let you choose the encoding. I can only tell you how to do it in Dreamweaver, if you are using a different editor, then I wouldn't know how to change the encoding for that.

haku thank you for your reply

 

sure , I saved the document in utf-8 from cpanel file editor

 

this is the code I used the php file :

 

header("Content-type : text/html ; charset=utf-8");

if ($_GET[t] && is_numeric($_GET[t])){

require_once('/home/myuser/public_html/vb/includes/config.php');

mysql_pconnect("localhost",$config['MasterServer']['username'],$config['MasterServer']['password']);

mysql_select_db($config['Database']['dbname']);

$post_title_q = mysql_query("select title from post where threadid=".intval($_GET[t])." and parentid=0");

$post_title=mysql_fetch_assoc($post_title_q);

$post_title[title] = mb_convert_encoding($post_title[title], 'UTF-8');

echo $post_title[title];

}

 

but language still appear like this :

ãÈÊÏÁ Úãá äÌã ÈÏÇÎáÉ áãÚÉ

 

note : the forum language is (arabic).

 

thanks for your time

 

Is your DB encoding UTF8?

If not, you need to change it. If it is, you have to tell the database you are expecting UTF8 using one of the following:

 

 

PHP below 5.0.7

mysql_query("SET NAMES 'utf8'");

 

PHP 5.0.7 or greater

mysql_set_charset('utf8');

 

Put this code after your DB connection.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.