By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,154 Members | 1,031 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,154 IT Pros & Developers. It's quick & easy.

Getting ???? while reading data from database which is in utf8_unicode_ci

100+
P: 245
Hi experts,
I have developed a website which is in russian language. I have integrated wordpress blog in it for news section. When i read the data from the database in my custom php page then it shows "?????" instead of showing russian characters. The wordpress database is in utf8_unicode_ci. When i post a news then it saves data in utf8_unicode_ci But when i read this data in my custom php page ( not in the wordpress template) then it shows "???????" instead of showing russian characters. Can some one guide me how can i do that. Here is my code which i am using to get the post content from the database.

Expand|Select|Wrap|Line Numbers
  1. $qs="select * from wp_posts where post_status='publish' order by ID desc limit 2";
  2. $rs = $db->Execute($qs);
  3. if($rs->RecordCount()>0){
  4. while(!$rs->EOF){
  5. $count++;
  6. <li>
  7. <p class="message">
  8. <span><?php echo $rs->fields('post_title');?></span><br />
  9. <?php echo substr($rs->fields('post_content'),0,150).'...!<br /><a href="'.$rs->fields('guid').'">Continue Reading</a>';?>
  10. </p>
  11. <div class="clear"></div>
  12. </li>
  13.  
Nov 18 '11 #1
Share this Question
Share on Google+
3 Replies


dlite922
Expert 100+
P: 1,584
Does your (X)HTML header look like this?
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  3.  
  4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  5. <head>
  6. <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
  7.  
change xml:lang="en" or "ru"?

and make sure you have charset=UTF-8 and the header as a meta tag.

You can also set it with php using header and content-type; charset http operators.

Dan
Nov 18 '11 #2

100+
P: 245
No it's xhtml 1.0
here is the format

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.     <head>
  4.         <base href="<?php echo PATH;?>" />
  5.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6.  
I changed en to ru but even then it wont work.....
Nov 19 '11 #3

P: 43
make sure you are using correct character encoding in the browser too.
Nov 20 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.