encoding problem

Discussion in 'PHP' started by hendkandeel, Feb 17, 2009.

  1. #1
    I made a site in bosnian language ,
    the problem is that some letters appears as (?) i used the following encodings:

    latin2_swedish
    utf-8
    ISO-8859-2

    they didn't succeed !!

    what encoding is suitable for webpages and mysql database?


    Thanks
     
    hendkandeel, Feb 17, 2009 IP
  2. tihan

    tihan Active Member

    Messages:
    64
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #2
    Try $var= iconv("UTF-8", "ISO-8859-2", $var); or something like that before inserting text to sql
     
    tihan, Feb 17, 2009 IP
  3. hendkandeel

    hendkandeel Peon

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Sorry , how i use that , i can't understand ?
     
    hendkandeel, Feb 17, 2009 IP
  4. tihan

    tihan Active Member

    Messages:
    64
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #4
    Well, I don't know where is the main problem with your code, but when I has the same problem, the iconv was the solution. :) For example, if you get the datas from form, and the character encoding works fine before you insert the datas to sql (eg. no problem with encoding if you try to echo/print the data), try the code above before the mysql_query command. I really don't know much about encoding, but I find this solution on google, and it's works for me.
     
    tihan, Feb 17, 2009 IP
  5. MC_delta_T

    MC_delta_T Member

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #5
    use UTF-8. it shows every language correctly. change dbs charset and your pages encoding to UTF-8. also you may send an sql query every page "SET NAMES UTF-8".
     
    MC_delta_T, Feb 17, 2009 IP
  6. hendkandeel

    hendkandeel Peon

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    here is my work !!
    in attachments

    thanks for all of you
     

    Attached Files:

    hendkandeel, Feb 17, 2009 IP
  7. MC_delta_T

    MC_delta_T Member

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #7
    change db charset Latin-1 to UTF-8.
     
    MC_delta_T, Feb 17, 2009 IP
  8. hendkandeel

    hendkandeel Peon

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Dear MC_delta_T,
    If you looked at the sql file you will find that the encoding of db is utf-8 !!
     
    hendkandeel, Feb 17, 2009 IP
  9. MC_delta_T

    MC_delta_T Member

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #9
    sorry i just looked this line

    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ;

    try this. add this code to every page ;

    mysql_query("SET NAMES 'utf8'")

    after db section.
     
    MC_delta_T, Feb 17, 2009 IP
  10. websecrets

    websecrets Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    The EASIEST way to fix this is to modify your httpd.conf file...

    AddDefaultCharset Off

    If it's set to "On" you will get "?" for non-standard characters.
     
    websecrets, Feb 17, 2009 IP
  11. hendkandeel

    hendkandeel Peon

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Dear MC_delta_T,
    I will try your solution , thanks

    Dear websecrets,
    Sorry,I can't understand what you said , please more explaination !! and where is this file???
    Exactly I got (?) instead of every character !!

    waiting your explaination
     
    hendkandeel, Feb 17, 2009 IP
  12. websecrets

    websecrets Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    httpd.conf is your Apache configuration file on your server... I'm assuming you are running Apache and have access to your server config files? If not then you'll have to use a scripted solution.
     
    websecrets, Feb 17, 2009 IP
  13. hendkandeel

    hendkandeel Peon

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    I am not working on a server , I work on a local host and upload my work to a site !!
     
    hendkandeel, Feb 18, 2009 IP
  14. hendkandeel

    hendkandeel Peon

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Dear MC_delta_T,
    thanks so much
    it worked with me
    thanks again
    ============
    another question :
    how can i print arabic contenet of a variable ?
    like
    &g="Ø£";
    echo $g;
    ???
    the result is :
    ?
     
    hendkandeel, Feb 25, 2009 IP