PHP UTF-8 encoding echoes question marks
According to http://php.net/manual/en/function.utf8-encode.php
utf8_encode
encodes data from ISO-8859-1 to UTF-8.
However, Polish lang has iso-8859-2 charset so you should use
iconv('iso-8859-2', 'utf-8', $d)
instead of utf8_encode($d)
You could try to execute
SET NAMES utf8
As a query. After you've made the connection.
Then just in case set this header
header('Content-type: text/plain; charset=utf-8');
Then try again