Special Characters in MYSQL

Discussion in 'PHP' started by kalsarao, Apr 13, 2008.

  1. #1
    Hi,

    I have a Table with VARCHAR(255) field. And when ever i Input Special Characters like ± or Copyright symbol. When i extract in PHP, the special characters are replaced by some Unidentified characters.

    Any idea where i am doing wrong?

    Please help.
     
    kalsarao, Apr 13, 2008 IP
  2. jmsala

    jmsala Guest

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    How are these chars stored into the database? utf-8, iso? you must define the encoding on your html and do the corresponding conversion on your string to match the page encoding. For instance if your database saves it as utf-8, set the page encoding to utf8, or if you use iso do a utf8_decode(). The other way around would be to have a database in iso and convert chars to utf8 with utf8_encode() if the page is using that encoding.

    hope this helps!
     
    jmsala, Apr 13, 2008 IP
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #3
    Use utf8 encoding for both the webpage and database.

    Peace,
     
    Barti1987, Apr 13, 2008 IP