Correct way of getting the current page uri

The built-in redirect_canonical() uses the following:

$requested_url  = is_ssl() ? 'https://' : 'http://';                                                                                                                                           
$requested_url .= $_SERVER['HTTP_HOST'];                                                                                                                                                       
$requested_url .= $_SERVER['REQUEST_URI'];

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