I am working on a php redirect script that stores a bunch of URL GET's in a mysql database. I've got the store figured out: $query = "INSERT INTO $db_table (id, ip_address, keyword1, keyword2) VALUES ('', '$ip_address' , '$keyword1' , '$keyword2')"; Code (markup): But after storing these variables I want the php script to redirect the user to a much shorter URL with only the mysql primary key id in the URL (the id is auto-incrementing). What is the best way to echo the id from the record I just created from the same php script? I'm really new to databases but I'm learning fast. Thanks for any help you can offer.