Problem in getting user comments permalinks

Hi @Ayaz Malik:

You need to use the function get_comment_link(). I’ve rewritten your code using some improved techniques and included the function call in place of what you had:

global $wpdb;
$sql =<<<SQL
SELECT
  {$wpdb->comments}.comment_ID,
  {$wpdb->comments}.comment_post_ID,
  {$wpdb->comments}.comment_content,
  {$wpdb->posts}.post_title
FROM
  {$wpdb->comments}
  INNER JOIN {$wpdb->posts} 
    ON {$wpdb->comments}.comment_post_id={$wpdb->posts}.ID
WHERE 1=1
  AND {$wpdb->comments}.user_id = %d
  AND {$wpdb->comments}.comment_approved = 1
ORDER BY
  {$wpdb->comments}.comment_ID DESC
LIMIT 5
SQL;
$sql = $wpdb->prepare($sql,$uid);  // $uid is assumed pre-defined before this code
$comments = $wpdb->get_results($sql, OBJECT);
if ($comments) {
  echo '<ul>';
  foreach ($comments as $comment) {
    setup_postdata($comment);
    $link = get_comment_link($comment->comment_ID);
    echo "<li><a href="https://wordpress.stackexchange.com/questions/8127/{$link}">Comment on {$comment->post_title}</a><br />" .
           "{$comment->comment_content}</li>";
  }
  echo '</ul>';
}