Custom Field returning Numerical Value for Image rather than URL

Use wp_get_attachment_image( $id ).

Sample code:

print wp_get_attachment_image( 
    $main_image,
    array ( 80, 80 ),
    FALSE, 
    array ( 'alt' => 'portrait' )
);

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