How do I link an image to the post it is attached to?

After some additional searching I was able to come across a function to generate the attachment ID here: http://pippinsplugins.com/retrieve-attachment-id-from-image-url/:

// retrieves the attachment ID from the file URL
function pippin_get_image_id($image_url) {
    global $wpdb;
    $prefix = $wpdb->prefix;
    $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts" . " WHERE guid='" . $image_url . "';"));
    return $attachment[0];  
}

and

$image_url="{my image url variable}";
$image_id = pippin_get_image_id($image_url);

Then I was able to combine it with another WordPress Answers thread here: Get the post attached to a image attachment:

$parent = get_post_field( 'post_parent', $image_id);
$link = get_permalink($parent);

Then added:

$my_post_title = get_the_title($parent);

Then output using:

<a href="'. $link .'">'.$my_post_title.'</a>

Hopefully that makes sense to other people, but I was surprised that I was able to get it all figured out being the novice that I