But if I use PDO's query function,there is all right without set charset: $result=$myPDO->query("SELECT * FROM guests ORDER BY lname,fname"); while($row=$result->fetch(PDO::FETCH_ASSOC)){ echo $row["fname"]." ". $row["lname"]; } 2010/5/21 cleverpig <greatcleverpig@xxxxxxxxx>: > hi, everybody! > > I encountered a problem using the PDO: > My mysql charset is utf-8, when using PDO's prepare () and statement's > execute() methods, > there is not the correct encoding resultset: > $ Statement = $ pdo-> prepare ("SELECT * FROM guests ORDER BY?"); > $ Statement-> execute (array ('lname')); > while ($ row = $ statement-> fetch (PDO:: FETCH_ASSOC)) ( > echo $ row ['fname']. "". $ row ['lname']; > ) > > But when I was make charset_set_results to be gbk, everything was normal: > $ Pdo-> exec ('SET character_set_results = gbk'); > > If PDO don't know which charset is fit to me,it will use default > charset(utf-8)?This is really mysql server charset! > > Anybody help me?Thanks! > > PS: I am using wamp (php5.3.1) > > -- > cleverpig(Dan) > Location: Beijing > Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China > Zipcode: 100031 > MSN: great_liudan@xxxxxxxxxxx > QQ: 149291732 > Skype: cleverpigatmatrix > Facebook ID:cleverpig > Blog: cleverpig.name/dan/ > Tags: del.icio.us/cleverpig > Twitter: twitter.com/cleverpig > 新浪微博: t.sina.com.cn/cleverpig > Organization: www.beijing-open-party.org > Organ@Facebook: http://www.facebook.com/group.php?gid=8159558294 > -- cleverpig(Dan) Location: Beijing Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China Zipcode: 100031 MSN: great_liudan@xxxxxxxxxxx QQ: 149291732 Skype: cleverpigatmatrix Facebook ID:cleverpig Blog: cleverpig.name/dan/ Tags: del.icio.us/cleverpig Twitter: twitter.com/cleverpig 新浪微博: t.sina.com.cn/cleverpig Organization: www.beijing-open-party.org Organ@Facebook: http://www.facebook.com/group.php?gid=8159558294 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php