i am trying to insert a link in an echoed line,
regular links work, but not this one, cant figure it out what's wrong

```
    if($gallery_images !=  ''){ 
        foreach ($gallery_images as $gallery_image){
            $thumb = wp_get_attachment_image_src($gallery_image[SN.'gallery_post_image']['id'], 'post-thumb', false);
            echo '<li><a  <a  href="'.the_permalink().'"><img src="'.$thumb[0].'" alt="'.$gallery_image[SN.'gallery_post_title'].'" /></a><p class="flex-caption">'.$gallery_image[SN.'gallery_post_title'].'</p></li>';
        }
    }

```