Mysql using utf8;
so when Rails and Php query records from tables should set encoding=utf8;
about Rails refer another article;
and the php,first be sure the editor save php file set the encoding utf8;
before query,add
mysql_query("set names utf8")