Alright,so we gonna create a URL shortening service in PHP this time,similar to tinyurl. The thing is pretty simple,involves basically database interactions only (nevertheless,tinyurl is a perfect example of how an idea can change the world,however simple it may be).
Anyway i have launched the service.Check it out: http://su.coolinc.info (I couldnt find a shorter domain)
The URL entered by the the user is mapped to a short string which could be either the alias entered by the user or a random string of length three(the length can be increased in case we run out of new combinations,then again 26*26*26 combinations should suffice (using only lower case alphabets)).This mapping is stored in a table url_short with fields url and alias (MySQL is the DBMS).
When the shortened URL is executed,the original URL corresponding to the alias is fetched from the database and the user is redirected to that page.
Heres the source of init.php,to generate the database and table for use. You will have to modify the argumets of mysql_connect() (server,usename,password) depending on the settings of the hosting provider.The below code is what i ran on my computer.

Setup script to create the database and table (MySQL)
Source of index.php,the main page

Source of index.php, the main page
Source of put.php,containing the script to insert the mapping into the database .

Source of put.php, the script to insert into database