phpMyAdmin understands requests if they come with data, for example, as 'Eaai', and in the script it is 'Ivan'.

echo $arr[$i]; // в Chrome выводится Иван $s = "SELECT SUM(`square`) FROM `reports` WHERE `username` = '".$arr[$i]."';"; // а сюда должно попасть 'Eaai', чтобы все выполнилось 

How to translate the encoding?

    2 answers 2

    So your data is not in cp1251. See for yourself: decoder - detects Eaai as 7-bit ASCII → ISO-8859-5 + CP1251 → ISO-8859-5

    See what mysql status; displays mysql status; you probably have not correctly configured mysql server. Although the file may not be in the original encoding, the server gives the answer in the wrong encoding ...

    Try this ob_iconv_handler - ob_iconv_handler .

    • look at the root of the question - the data came in the wrong encoding, there is nothing to blame on muscle, you have to train at the parish - oldzas
    • Help: - oldzas pm
    • what encoding do you have in bd? - oldzas
    • utf-8 unicode ci - Anna
    • Save the document (script) in UTF-8 and, according to the idea, the problem will be solved. - evlanoff

    Use iconv .

    • tried so echo $ arr [$ i]; $ mes = iconv ("cp1251", "UTF-8", $ arr [$ i]); $ s = "SELECT SUM ( square ) FROM reports WHERE username = '$ mes';"; but the request was also not fulfilled .. ( - Anna
    • failed to execute - what was the error? or just nebylo conversion? - oldzas 5:53 pm
    • the conversion was executed .. the query turned into SELECT SUM ( square ) FROM reports WHERE username = 'Р˜РІР ° РЅ'; but not satisfied .. - Anna