I try to get attachment url wordpress's post and i use 2 functions
get_post_thumbnail_id - If a featured image (formerly known as post thumbnail) is set - Returns the ID of the featured image attached to the post
wp_get_attachment_url Returns a full URI for an attachment file or false on failure.
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
Hope this small tip can help you to build your professional wordpress theme