How to get the result of comments_number() as a string instead of printing it out?

Easiest way:

ob_start();
comments_number();
$data = ob_get_clean();

$data will contain the text.

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