The internet has many sites that use short links. For example youtube, tinyurl and similar services. A link like: http://www.youtube.com/watch?v=N98cpA5hdI0 is far nicer than http://www.youtube.com/watch?v=23450928230945820532. Short links are also necessary if we do not want our site to be easily scraped. Beginner programmers very often try to create links of this kind on their own sites. But they do it in a very strange way: usually they create a string with a random sequence, check whether a similar one already exists in the database, and if it does, create a new one and check again. This is a very expensive approach, and the database ends up as a mess of character sets. I am not arguing, it is also a solution, and a very correct one, but not an optimal one. People usually arrive at this solution after reading forums, Q&A sites, or searching on Google. Optimal solution: use mysql in its usual form, create an id field of type int \ bigint, and use auto_increment for this field. Many people think the index will suddenly become huge and overflow, but those are vain fears. If the program logic is correct, you simply will not reach the int/bigint limits. But how do short links appear? Use base62 with a small change: for example, we want a link like XXXXX, and to get it we just add an arbitrary value to your id from the database.
class BaseConv {
  private static $base = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  public static function Base10($value, $b = 62) {
    if (!preg_match("/^[a-zA-Z0-9]+$/", $value)) return -1;
    $limit = strlen($value);
    $result = strpos(static::$base, $value[0]);
    for($i = 1; $i < $limit; $i++) {
      $result = $b * $result + strpos(static::$base, $value[$i]);
    }
    return $result;
  }
  public static function BaseX($value, $b = 62) {
    $r = $value  % $b;
    $result = static::$base[$r];
    $q = floor($value / $b);
    while ($q) {
      $r = $q % $b;
      $q = floor($q / $b);
      $result = static::$base[$r].$result;
    }
    return $result;
  }
}

function idToUrl($id) {
  return BaseConv::BaseX(100000000000 + $id);
}

function idFromUrl($id) {
  return BaseConv::Base10($id)-100000000000;
}
This simple code will help you in your endeavors. And if you want every link to come from a unique set of characters, just shuffle the bits by a mask and change the order in the base character set. The rest is up to your imagination.