Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7989671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:49:08+00:00 2026-06-04T12:49:08+00:00

I know creating a short url algorithm isn’t as easy as hashing a URL

  • 0

I know creating a short url algorithm isn’t as easy as hashing a URL then chopping the hash down to some incremental version of itself. Even though from an outside perspective that is what it looks to be happening. I’ve read a few articles on the idea, seen a couple in action as well. But none seem to worry about future proofing it.

So I am here trying to find out how I can approach this with PHP and find ways that I can avoid at the least common problems. From database conflicts to whatever else there may be to worry about other than overall storage and database size.

One problem I will definitely face is the service I am creating is taking user-side URL from another service my buddy is creating so on a per user basis we are tracking there short URLs so its possible multiple users could end up using the same exact long url but we will need a different short url id for each user who is supplying a URL. Think of several users sharing a youtube video that recently went viral..

So whats the best tactic at creating a short url algorithm that wont face many bash’s at the same time will allow me to query my DB with a handful of possible short URLs to see if they already exist or not.

Better yet is there some means I can create unique id’s via mySQL functionality, that would in concept loop til one is unique and thusly created for the cause?

I know Im pulling at straws here and this is a rather open question. But I am trying to think tactfully before getting heavy into the build process to only later find out I messed up big. I kinda need some input prior to make sure I am taking a semi sane approach to this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:49:10+00:00Added an answer on June 4, 2026 at 12:49 pm

    You can use this short URL algorithm made in PHP – it generates four different “hashes” of the same url.

    Create a table like

    id |    original_url        |   short_url
    ------------------------------------------
    1    http://www.google.com/     tm5kxb
    

    When user inputs an URL to shorten, you use the function from the article and receive an array of four different hashes. Then you can use a query like:

    SELECT id FROM {your_table} WHERE short_url = "{a_hash_from_the_function}"

    If the query returns no results, then it means that there was no match and you can use this one. If the query returns a result, simply use another hash from the array, see if it exists, and so forth.

    Read the whole article as in the bottom the author explains how to make your hashes more unpredictable. I would suggest using a different hashing algorithm than md5(), but you will have to experiment yourself. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a paint app and I want to know how to implement
I know you can specify a different layout file for orientation by creating a
I am creating a CMS and want to know if its possible to download
I'm creating a jquery plugin for sorting and pagination a table (I know that
I am creating an iphone performance app in which I would like to know
I want to know what is the best solution for creating ASP.NET HTTP Handler
I know how to set the cursor position of the console, but upon creating
I am creating an .ics file in Java, and I need to know what
I am creating a non-deterministic orchestration to handle convoys. I know I am setting
I'm creating a popup window with no URL source using window.open(). I don't give

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.