How to get special chars from mysql database

Discussion in 'PHP' started by 123GoToAndPlay, Jan 25, 2009.

  1. #1
    So i copy paste text into mysql, but now i get strange hearts and diamonds.

    Chars i have in a tabel are € and '

    the tablefield is utf8_general_ci


    any tips
     
    123GoToAndPlay, Jan 25, 2009 IP
  2. Dennis M.

    Dennis M. Active Member

    Messages:
    119
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Odd. I have those chars in a utf8_general_ci collated table and they work fine. What are you trying to do exactly and where are you getting the problem?

    Regards,
    Dennis M.
     
    Dennis M., Jan 25, 2009 IP
  3. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #3
    What interface are you using ? is it phpMyAdmin?

    Anyways, I think you have to do a SET NAMES 'utf8_general_ci' first
     
    nabil_kadimi, Jan 25, 2009 IP
  4. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    indeed, i am using phpmyadmin,

    Could you explain the SET NAMES 'utf8_general_ci' part???

    btw: at the moment i copy +paste the special characters straight into the mysql db with phpmyadmin.
     
    123GoToAndPlay, Jan 27, 2009 IP
  5. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    ah found it i think.

    By adding
    
    mysql_query("SET CHARACTER SET utf8");
    mysql_query(”SET SESSION collation_connection =’utf8_general_ci’”);
    
    Code (markup):
    This saves me a lot time. Don't have to replace € etc
     
    123GoToAndPlay, Jan 27, 2009 IP