mysql_set_charset("cp1251", connection);
mysql_function_query(connection,"SET NAMES 'utf8'",false,"","");
mysql_function_query(connection,"SET CHARACTER SET 'cp1251'",false,"","");
mysql_function_query(connection,"SET SESSION character_set_server='utf8'",false,"","");