Ok, I've after really long time trying many options found the solution:
instead of writing this:
$sql = mb_convert_encoding($sql, "UTF-8");
there should be written this:
$sql = mb_convert_encoding($sql, "UTF-8", "ISO-8859-2");
while you should make sure your text is written in this format ISO-8859-2
f.e. in your head tag by having this in there: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2"/>