nasser bahaj Posted April 12, 2010 Share Posted April 12, 2010 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 More sharing options...
haku Posted April 13, 2010 Share Posted April 13, 2010 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. Link to comment https://forums.phpfreaks.com/topic/198326-help-in-convert-encoding-to-utf-8/#findComment-1040644 Share on other sites More sharing options...
nasser bahaj Posted April 13, 2010 Author Share Posted April 13, 2010 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 Link to comment https://forums.phpfreaks.com/topic/198326-help-in-convert-encoding-to-utf-8/#findComment-1040903 Share on other sites More sharing options...
haku Posted April 13, 2010 Share Posted April 13, 2010 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. Link to comment https://forums.phpfreaks.com/topic/198326-help-in-convert-encoding-to-utf-8/#findComment-1040957 Share on other sites More sharing options...
nasser bahaj Posted April 13, 2010 Author Share Posted April 13, 2010 thank you MR haku the DB is utf-8 mysql version is : 5.0.89 so I used mysql_set_charset('utf8'); after DB connection line this is the page , you can see it http://downloads.de4school.com/index2.php?t=199 thank you Link to comment https://forums.phpfreaks.com/topic/198326-help-in-convert-encoding-to-utf-8/#findComment-1041006 Share on other sites More sharing options...
haku Posted April 14, 2010 Share Posted April 14, 2010 What's your PHP version? Link to comment https://forums.phpfreaks.com/topic/198326-help-in-convert-encoding-to-utf-8/#findComment-1041412 Share on other sites More sharing options...
nasser bahaj Posted April 14, 2010 Author Share Posted April 14, 2010 thank you Mr haku php version is : 5.2.11 Link to comment https://forums.phpfreaks.com/topic/198326-help-in-convert-encoding-to-utf-8/#findComment-1041617 Share on other sites More sharing options...
haku Posted April 15, 2010 Share Posted April 15, 2010 Everything looks fine to me. I'm going to move this to the PHP section of the forum as the problem doesn't look to be HTML based, and you are more likely to get help there. Link to comment https://forums.phpfreaks.com/topic/198326-help-in-convert-encoding-to-utf-8/#findComment-1042125 Share on other sites More sharing options...
nasser bahaj Posted April 15, 2010 Author Share Posted April 15, 2010 thank you Mr haku I hope any body can solve this problem . Link to comment https://forums.phpfreaks.com/topic/198326-help-in-convert-encoding-to-utf-8/#findComment-1042229 Share on other sites More sharing options...
nasser bahaj Posted April 17, 2010 Author Share Posted April 17, 2010 thanks to every one helps me I found that my db is in windows-1256 encoding I converted the title via this function iconv(); problem solved thanks Link to comment https://forums.phpfreaks.com/topic/198326-help-in-convert-encoding-to-utf-8/#findComment-1043688 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.