$sql = "SELECT id, link, shortlink FROM $tbl_name WHERE link='$dest'";
$result = mysql_query($sql);
$count = mysql_num_rows($result);
if($count == 1){
while ($row = mysql_fetch_assoc($result)){ // Attempt to pull all data concerning that one user from table
$id = $row['id'];
$link = $row['link'];
$short = $row['shortlink'];
echo "From what I can tell, this particular link was already shortened before.<br>Here's the link: <a href=\"http://unps.us/?l=$short\">http://unps.us/?l=$short</a>";
$sql="INSERT INTO $tbl_name (link, shortlink) VALUES ('$dest', '$short')";
$result=mysql_query($sql);
if($result){
echo "It appears that I have succeded in making a short link.<br>You'll find it here: <a href=\"http://unps.us/?l=$short\">http://unps.us/?l=$short</a> ";
}else {
echo "There was a problem trying to register your link - Could be a database error";