[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Character endoding after reading from db

Posted on 2009-03-30
3
Medium Priority
?
282 Views
Last Modified: 2013-11-19
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)");
	//$um=mysql_num_rows($ans);
	//if($um!='0')
	while($um=mysql_fetch_array($ans)) 
		{
		$us=mysql_query("SELECT username FROM `jr_comments`WHERE `id` = '$um[revid]'");
		while($av=mysql_fetch_array($us))
			{
			echo '<b>'.$av[username].':</b>';
			echo "$um[jr_comment]";
			echo "<br>";
		}
		}

Open in new window

0
Comment
Question by:TheSilverBullet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 2000 total points
ID: 24017138
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

0
 
LVL 3

Expert Comment

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

Open in new window

0
 

Author Closing Comment

by:TheSilverBullet
ID: 31564219
Bravo!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question