471,071 Members | 1,173 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

Cannot retrieve greek characters from database.

Hi, i have made a database using phpmyadmin. All encoding of the database is set to utf8_general_ci. The php code is written in UTF-8 without BOM. The problem is that despite the fact that i can insert greek characters via a login form, which appear properly inside the database tables, when i retrieve them they are displayed in the browser like this ???????. I checked some similar topics but could not figure some solution.
May 25 '10 #1
7 2416
5,000 Expert 4TB
Does the browser have greek language support installed?
May 25 '10 #2
5,000 Expert 4TB
Also, what software is between your database and your web browser? If you are using phpmyadmin and you can see the characters appropriately in the browser using that application but with the same browser using your application they do not appear properly I would say the issue is with your application.

We're going to need to see some source code in the areas of where you retrieve the data from the database and around where you display it to the user.
May 25 '10 #3
Here is a function i use to fill a drop down list with enum values from my database
Expand|Select|Wrap|Line Numbers
  1. function optionlist(){ 
  2.     $result=mysql_query('SHOW COLUMNS FROM mathimata WHERE field=\'examhno\'');
  3. while ($row=mysql_fetch_row($result))
  4. {
  5.     $r = $_GET['Result'];
  6.    foreach(explode("','",substr($row[1],6,-2)) as $v){
  7.    if ($v==$r)
  8.    {
  9.      print("<option selected>$v</option>");
  10.    }
  11.    else
  12.    {
  13.    print("<option>$v</option>");
  14.    }
  15.    }
  16. }  
  17. }
May 25 '10 #4
5,000 Expert 4TB
What is that gobbledygook? Is it PHP?
May 25 '10 #5
It is PHP, sorry for the bad syntax/programming but it's been like a month since i started with php. Also another simple PHP function i used is this
Expand|Select|Wrap|Line Numbers
  1.     $sql = "SELECT firstname FROM `login` where id=\"5\"";                                       
  2.     $result = mysql_query($sql) or die('error');  
  3.     $result = mysql_fetch_array($result); 
  4.     echo $result['firstname'];
May 25 '10 #6
5,000 Expert 4TB
No, I just ask because I can't read PHP, and I now have to move your thread to PHP.
May 25 '10 #7
I figured a solution i put this lines right after every connection to database

mysql_query("SET CHARACTER SET 'utf8'");
mysql_query("SET NAMES 'utf8'");
May 25 '10 #8

Post your reply

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

Similar topics

27 posts views Thread by alexdoulou | last post: by
2 posts views Thread by chanmm | last post: by
reply views Thread by Georg | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.