error in getting post id

On a default install of WP you get always the ID of a post with the function get_the_ID(). Id dosnt work this you go about the global var: $post.

echo $GLOBALS['post']->ID

Is this not enough, then go about the global wp_query

$GLOBALS['wp_query']->post->ID;

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