Getting weird characters when fetching value in mysql database

前端 未结 3 2008
执念已碎
执念已碎 2020-12-21 14:03

I\'m getting this kind of result in my database ’ everytime i\'m typing this character

I already use mysql_query(\'SET CHARACTER

3条回答
  •  难免孤独
    2020-12-21 14:31

    try to do a select with a charset collate and use utf8_bin like this:

    SELECT k COLLATE utf8_bin AS k1
    FROM t1
    ORDER BY k1;
    

    if it works for you, you can change the collate for a column by using alter table, here is an example I used today for one of my dbs: (you could do this also with phpMyAdmin easily)

    ALTER TABLE  `users` 
    CHANGE  `name`  `name` VARCHAR( 255 ) 
    CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
    

    but make a backup first!

提交回复
热议问题