joesaddigh Posted March 16, 2009 Share Posted March 16, 2009 I am trying to offer a language translation on my site. I am trying to implement this dynamically from a language table. I have encoded the database to utf 8 and the arabic characters are being displayed in the database but when i get them from the databse and echo them to the screen it just displays question marks. Is there something i need to do in order to get the browser to display the arabic characters.... The code that gets the text is as follows: elseif (isset($_GET['language'])) { $language = $_GET['language']; echo $language; //Get the selected language text from the database require "connectstudent.php"; $query = "select * from language where language = ''"; $result = mysql_query($query, $conn) or die ("Unable to get selected language".mysql_error()); //Get the languageID $querylanguageid="SELECT LanguageID FROM language WHERE Language = '$language'"; $resultlanguageid=mysql_query($querylanguageid) or die("error getting languageid"); $rowlanguageid = mysql_fetch_assoc($resultlanguageid); $languageid=$rowlanguageid['LanguageID']; echo $languageid; $querylanguage= "SELECT language.LanguageID, language.Language, languagepage.LanguageID, languagepage.PageID, languagepage.Section, languagepage.Text FROM language INNER JOIN languagepage ON language.LanguageID = languagepage.LanguageID WHERE languagepage.LanguageID = '$languageid' AND languagepage.PageID = 1 AND languagepage.Section = 'rightcolumn'"; $resultlanguage = mysql_query($querylanguage, $conn) or die ("The join query is not working"); while($row= mysql_fetch_array($resultlanguage)) { //HTTP_ACCEPT_LANGUAGE Experiment to see if this is needed get parse error when using this //$languagetext =$HTTP_ACCEPT_LANGUAGE $row['Text']; $languagetext = $row['Text']; echo $languagetext; } If anybody has any knowledge of this problem i would be really grateful for some advice Thanks Link to comment https://forums.phpfreaks.com/topic/149693-solved-multilingual-website/ Share on other sites More sharing options...
Mchl Posted March 16, 2009 Share Posted March 16, 2009 Send SET NAMES 'utf8' query to MySQL right after connecting. Link to comment https://forums.phpfreaks.com/topic/149693-solved-multilingual-website/#findComment-786056 Share on other sites More sharing options...
joesaddigh Posted March 16, 2009 Author Share Posted March 16, 2009 Im not sure i understand what you are saying please could you be more specific? Thanks Link to comment https://forums.phpfreaks.com/topic/149693-solved-multilingual-website/#findComment-786132 Share on other sites More sharing options...
Mchl Posted March 16, 2009 Share Posted March 16, 2009 Run mysql_query("SET NAMES 'utf8'",$conn); right after $conn = mysql_connect(... (this is probably in connectstudent.php) Link to comment https://forums.phpfreaks.com/topic/149693-solved-multilingual-website/#findComment-786260 Share on other sites More sharing options...
joesaddigh Posted March 17, 2009 Author Share Posted March 17, 2009 Your a life saver, i thought i was going to have to change my whole logic!! Thanks Link to comment https://forums.phpfreaks.com/topic/149693-solved-multilingual-website/#findComment-786519 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.