Character endoding after reading from db

the snippet bellow, it retrieves some data from the db and renders it, it works find except that the rendered text in line echo "$um[jr_comment]"; is displayed like ??? ?????? ????? (question marks) when the letters are non-latin (they are Arabic letters) , is there a way to avoid that?

the rest of the page is displaying correctly because it is done thru joomla, that portion is the only non-standard part of the page that reads directly from the db.
$ans=mysql_query("SELECT * FROM `jr_review_fields`WHERE reviewid in (	$alist)");
		$us=mysql_query("SELECT username FROM `jr_comments`WHERE `id` = '$um[revid]'");
			echo '<b>'.$av[username].':</b>';
			echo "$um[jr_comment]";
			echo "<br>";

Open in new window

Who is Participating?
Ryan ChongConnect With a Mentor Commented:
try execute this statement before your Select SQL statement:

$result = mysql_query('SET NAMES utf8;');


$ans=mysql_query("SELECT * FROM `jr_review_fields`WHERE reviewid in (   $alist)");


you may also change the meta setting to be like this:

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

hope this helps

try to put this code at the begining of this php file
header("Content-type: text/html; charset=windows-1256");

Open in new window

TheSilverBulletAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.