Try using SET NAMES utf8
after connecting to MySQL:
mysql_query("SET NAMES utf8");
Or if you are using cp1251 in the database, set this encoding.
As the manual says:
SET NAMES indicates what character set the client will use to send SQL statements to the server... It also specifies the character set that the server should use for sending results back to the client.