Problem with Greek characters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Punkis
    New Member
    • Sep 2008
    • 12

    Problem with Greek characters

    Hi all,

    I have a problem with my php and mysql project.
    I use an auctions software, named phpauction for my project.

    I import into my database with utf8 encodingm and I can see the greek letters inside the fields.
    The problem is that when i go to the site for the results, I get question marks instead of the greek characters.
    I have searched a lot, and i found that there is a solution by adding mysql_query("SE T NAMES utf8") after mysql_select_db .

    Is that correct?
    Also, i can not find the mysql_select_db in any of the files.


    P.S. When I import to mysql i do it from a notepad file that i save it to *****.sql
    I used the default encoding and utf8 encoding but nothing.

    i export the query i imported and did these:
    I uploaded in the sever and with default encoding Greek, it was displayed correctly. I changed browser encoding to UTF8 and i got question marks.
    Then using Notepad again i saved it with utf-8 encoding and now it is displayed correctly with UTF8 encoding select by default to the browser.
    So, I guess some of my pages are not designed for utf8 encoding.
    If it is so, that gives me two options.
    A. To get the html code of all my pages, open it with notepad and encode it with utf8
    B. To put the meta charset for utf8 to all of my pages. ( Have in mind that i did that for the pages that are used for the searching section, and also I did it with the combination of saving it with notepad in utf8 )
    Also, I import some items for the importing/exporting test you told me.
    I have mysql and collations to utf8 general ci

    1. Using the default encoding of notepad,I import the sql file and i got question marks. i did not exported it.
    2. I saved the sql with utf8 encoding now. I uploaded it and mysql displays it right. I searched it through the site and it gave me question marks again. The encoding of browser is set to UTF8. Then i exported it from mysql, saved it into html, uploaded it, opened it and with greek encoding (default is right) utf8 gives me question marks
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    Are you filtering the data in your PHP code before printing it?
    Like say, by using the htmlentities function?

    It could be that your data is being stored correctly in MySQL, but being treated incorrectly by PHP before it is echoed.

    Comment

    • Punkis
      New Member
      • Sep 2008
      • 12

      #3
      Hi, thank you for your reply.

      I tried to find the file that does this work (as i said is not developed by me)
      and found this :

      [PHP]/* this subastas title and link to details */
      $tplv['id']=$row['id'];
      $tplv['idformat']="<A HREF=\"".$SETTI NGS['siteurl']."item.php?id=" .$row['id']."\">";

      $tplv['idformat'] .= stripslashes(ht mlspecialchars( $row['title'])); $tplv['idformat'].= "</FONT></A>";[/PHP]


      so i guess there must be something with this
      $tplv['idformat'] .= stripslashes(ht mlspecialchars( $row['title']));

      but i do not know what!
      Last edited by Atli; Sep 20 '08, 04:57 PM. Reason: Added [code] tags.

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Yea, that's it.

        The htmlspecialchar s function will use the default ISO charset unless you specify the charset in it's 3'rd parameter.

        Like, for example:
        [code=php]
        echo htmlspecialchar s($unicodeText, ENT_COMPAT, "UTF-8");
        [/code]

        Comment

        • Punkis
          New Member
          • Sep 2008
          • 12

          #5
          I changed it to this

          Code:
          $tplv['idformat'] .= stripslashes(htmlspecialchars($row['title'], ENT_COMPAT, "UTF-8"));
          but again, nothing..
          Is there any chance that the greek letters into the queries i import are not written in utf8?

          Comment

          • Atli
            Recognized Expert Expert
            • Nov 2006
            • 5062

            #6
            Yea, that should work.
            Does it?

            Comment

            • Punkis
              New Member
              • Sep 2008
              • 12

              #7
              Originally posted by Atli
              Yea, that would work.

              That is; if you replace your two dotted lines with the two extra parameters I posted above (ENT_COMPAT and "UTF-8").
              but again, nothing..

              Is there any chance that the greek letters into the queries i import are not written in utf8?
              I do save my sql before i import it with notepad and i encode it with utf8

              Comment

              • Atli
                Recognized Expert Expert
                • Nov 2006
                • 5062

                #8
                It could be written in any number of char sets.

                Greek characters can be encoded in a lot of different char sets.
                The ISO-8859-7 char set is a specialized Greek char set I believe.

                If it is encoded in that, it would be displayed incorrectly as UTF-8.

                Does it work in either one?
                Try changing the charset of the browser. See if anything makes it look right.

                (You can change it on the fly in many browsers. In Firefox you can do: View->Character Encoding... and just select one from the list)

                Comment

                • Punkis
                  New Member
                  • Sep 2008
                  • 12

                  #9
                  my the pages that take part for the search are encoded to utf8 and meta charset to utf8 too.
                  I import the query encoded with utf8 into a utf8_general_ci table into a utf8_general_ci mysql.

                  And the problem still remains.
                  I think the problem is in that line you told me.
                  Maybe changing htmlspecialchar s with something else.

                  also,
                  when i write into a page from the html editor Greek letters, then if i want to edit it again it shows me this. If i convert the Greek letters like below? What encoding is that? When i firstly posted it her it covert it to greek letters! :P

                  <tr><td>Μπορείτ ε να καταχώρησετ ε τα προιόντα </td></tr>
                  & # 9 2 4 ; & # 9 6 0 ; & # 9 5 9 ; & # 9 6 1 ; & # 9 4 9 ; & # 9 4 3 ; &# 96 4; &# 94 9; να

                  without spaced

                  Comment

                  • Atli
                    Recognized Expert Expert
                    • Nov 2006
                    • 5062

                    #10
                    Those are HTML encoded characters. They aren't really a charset, but rather html *entities* that represent a character regardless of the charset the page is using.
                    For example, &#93 ; (without the space) represents &#93;

                    This isn't how it is stored in your database is it?

                    If this is caused by the htmlspecialchar s function, then you could remove the function just to see if it fixes it. If that doesn't fix it, it's something else.

                    That is; try this:
                    [code=php]
                    $tplv['idformat'] .= $row['title'];
                    [/code]
                    And post what that does.

                    Comment

                    • Punkis
                      New Member
                      • Sep 2008
                      • 12

                      #11
                      nothing again... i am loosing my mind
                      :(

                      Comment

                      • Punkis
                        New Member
                        • Sep 2008
                        • 12

                        #12
                        Until 10 minutes ago, the results could not display me correctly the Greek characters from mysql.
                        The search system searches the title of the item which contains English and Greek characters.

                        I solve this problem with this :
                        I use notepad for any encoding i do between ansi, unicode and utf8.
                        I wrote into notepad the title in English and for the Greek letters i wrote them in HTML encoded characters and i saved it as ANSI.

                        On phpmyadmin I uploaded the file choosing utf8 for Character set of the file and ANSI for sql compatibility.

                        i searched for that English word i wrote in the title and displayed to me the result WITH GREEK LETTERS correctly.
                        This is the only way to display Greek letters. I tried everything.

                        The problem is :
                        When i searched using that Greek letters that i wrote in the title the result showed me nothing. Then i searched again using the HTML encoded characters i used for that title and i got the result with Greek letters!

                        Having in mind that with HTML encoded characters the system found me the result, I guess there must be a line that it will convert the Greek characters to HTML encoded characters before it gives me the results.

                        Anyone knows anything about this?

                        Comment

                        • Punkis
                          New Member
                          • Sep 2008
                          • 12

                          #13
                          My greek data is written in the database using the decimal format http://htmlhelp.com/reference/html40/entities/symbols.html

                          The only way to get the results displayed is when i search with those decimal codes.

                          I want to convert the greek letters that i write in the searchbox to those decimal codes before it gives me the results, with this way i will get the correct search results.

                          Comment

                          Working...