Greek Letters Problem: Help for Suggestions:

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • burrashiva
    New Member
    • Feb 2008
    • 5

    Greek Letters Problem: Help for Suggestions:

    Hi All,

    I have an Editor through which I want to send Greek Symbols for which I am using &#913 etc representation.
    I have an HTML template page where this Editor is called.
    Through MOOTOOLs ajax function, I am sending it to PHP which inserts the content of the Editor into MySQL Database.
    The problem:
    Then I have to retrieve the content. On retrieval, the Symbols are lost - I mean they are not shown as symbols but some gibberish/ gobblygook characters.

    I read couple of forums: They say it is Character Set problem. I tried these things:

    changed the <meta tag content type > to "UTF-8" in HTML file.
    Editor Content is encoded before sending to PHP. Ajax function of Mootools is by default - UTF-8
    Till this point, the symbols are seen correct - as seen in the firebug tracker on firing ajax request.
    In PHP - I use HTMLEntities function and encode , then add slashes using addslashes.
    Then - I send the content to MYSQL. where I have used specific - set names utf-8 and
    set character set UTF-8 as well.

    I hope I am doing the right thing.
    When I started retrieving the content, I use stripslashes, then html_entity_dec ode , then via ajax, gets back to the editor where it is again decoded.
    At this point, the characters have lost their meaning - they are some thing else. no more symbols.

    Where am I going wrong ? This seems to be a common problem. I read the earlier posts as well, but I could not get a concrete solution. So I tried all that was available as suggestions. but to no use.

    for testing : http://sgwiki.sdsc.edu ,
    login: guest
    password: guest123

    browse and pick any name listed and start editing for example : Abstract. Enter symbols using the 'a' icon in the editor tool bar.
    publish it you will see the problem.
    Any suggestions will be greatly appreciated.

    Thank you very much.
    Prasad.
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    did you tried
    mysql_real_scap e_string other then addslash?

    I have also faced a wiered problem in MySQL 5. I have to work with japanese character set. The problem is with the column(entity) encoding. If it is set to EUC and send data as SHIFT_JIS data get destroyd and same thing happen while column encoding is declared as SHIFT_JIS and save EUC data. I think you should also check the "Collation" of column.

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Originally posted by burrashiva
      In PHP - I use HTMLEntities function and encode...
      Do you set the third parameter of htmlentities?
      It's a common error to forget that. (I forget it all the time xD)

      If that's not it, could you perhaps post the relevant code snippets here? It would be easier to spot any problems that way.

      Comment

      • burrashiva
        New Member
        • Feb 2008
        • 5

        #4
        Hi ,
        Sorry for the delayed reply. But here are my trials after taking your suggestions. I thought better I post the code snippets.

        While going into the Mysql from Client:

        In the javascript:
        var qstr = "editorid="+mym ythis.editorid+ "&content="+url encode(stringco nt);

        Probably mootools request does encoding again (whats the influence of that I have no clue) but by default the encoding while AJaX request - its encoded.

        After reaching PHP:
        $tablecont = addslashes( htmlentities(tr im($_POST['content']),ENT_QUOTES, "UTF-8") );

        @johnny... did you mean to replace addslashes with mysql_real_esca pe_string function??? Will try after I get a reply to this ..

        before inserting into the Database:
        $mm = new WadaMysql();
        $mm->query('use sgmpv2');
        $mm->query('SET NAMES utf8');
        $mm->query("SET CHARACTER SET 'utf8'");

        This saves the content as : for alpha beta and gamma :
        &beta;&alpha;&g amma;

        Now the retrieval code:

        before connecting to mysql:
        $mm = new WadaMysql();
        $mm->query('use sgmpv2');
        $mm->query('SET NAMES utf8');
        $mm->query("SET CHARACTER SET 'utf8'");

        in PHP:
        echo utf8_encode(htm l_entity_decode (stripslashes($ row['content']),ENT_QUOTES,"U TF-8"));

        Then the ajax default - may be it decodes or keeps encoding - I dont know.

        Once it reaches the client:
        urldecode(respo nseText);

        the javascript urldecode and urlencode are downloaded from phpjs.

        any suggestions , pl. help.
        Prasad.

        Comment

        • burrashiva
          New Member
          • Feb 2008
          • 5

          #5
          WooooooooW!!

          Okay, after all that, I just removed the the
          UTF8_encode, html_entity_dec ode functions while retrieving the content.

          It seems to be showing the symbols correctly.

          Am I doing correctly?
          pl give your suggestions?
          I feel there may be some security lapses because of removing these functions..I dont know. Pl. enlighten on that aspect too.

          Thank you very much for the help.
          Prasad.

          Comment

          Working...