Cannot retrieve greek characters from database.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • agelosd
    New Member
    • May 2010
    • 4

    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.
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    Does the browser have greek language support installed?

    Comment

    • RedSon
      Recognized Expert Expert
      • Jan 2007
      • 4980

      #3
      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.

      Comment

      • agelosd
        New Member
        • May 2010
        • 4

        #4
        Here is a function i use to fill a drop down list with enum values from my database
        Code:
        function optionlist(){ 
        	$result=mysql_query('SHOW COLUMNS FROM mathimata WHERE field=\'examhno\'');
        while ($row=mysql_fetch_row($result))
        {
        	$r = $_GET['Result'];
           foreach(explode("','",substr($row[1],6,-2)) as $v){
           if ($v==$r)
           {
             print("<option selected>$v</option>");
           }
           else
           {
           print("<option>$v</option>");
           }
           }
        }  
        }

        Comment

        • RedSon
          Recognized Expert Expert
          • Jan 2007
          • 4980

          #5
          What is that gobbledygook? Is it PHP?

          Comment

          • agelosd
            New Member
            • May 2010
            • 4

            #6
            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
            Code:
            	$sql = "SELECT firstname FROM `login` where id=\"5\"";                                       
            	$result = mysql_query($sql) or die('error');  
            	$result = mysql_fetch_array($result); 
            	echo $result['firstname'];

            Comment

            • RedSon
              Recognized Expert Expert
              • Jan 2007
              • 4980

              #7
              No, I just ask because I can't read PHP, and I now have to move your thread to PHP.

              Comment

              • agelosd
                New Member
                • May 2010
                • 4

                #8
                I figured a solution i put this lines right after every connection to database

                mysql_query("SE T CHARACTER SET 'utf8'");
                mysql_query("SE T NAMES 'utf8'");

                Comment

                Working...