Why does wp_head hook my functions to the beginning of my source code?

It doesn’t. You’ve written the PHP tag incorrectly, so your code is being printed to the browser instead of being run. You have <php?. It’s supposed to be <?php.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)