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 322389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:56:04+00:00 2026-05-12T08:56:04+00:00

I have a mssql database in which my primary keys are GUIDs. I am

  • 0

I have a mssql database in which my primary keys are GUIDs. I am working on a web interface for inserting some data. I need a GUID, generated by php. I am using com_create_guid() function. So, before trying to insert I want to ensure that my parameters are valid. I can not find a way to check if a string(com_create_guid() returns string) is a valid GUID.

  • 1 1 Answer
  • 3 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-05-12T08:56:04+00:00Added an answer on May 12, 2026 at 8:56 am

    Considering a GUID is defined as something like this : “A98C5A1E-A742-4808-96FA-6F409E799937” (from what the wikipedia page says)

    I suppose using a regex like this one would do :

    $guid = 'A98C5A1E-A742-4808-96FA-6F409E799937';
    if (preg_match('/^\{?[A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}\}?$/', $guid)) {
      var_dump('ok');
    } else {
      var_dump('not ok');
    }
    

    It will match for

    • 8 characters (both letters and numbers)
    • 4 characters
    • 4 characters
    • 4 characters
    • 12 characters

    Each set of characters being separated by a ‘-‘

    Considering you’re using com_create_guid, the regex check for optionnals } and { arround the guid, which means this would display ‘ok’ too :

    $guid = '{A98C5A1E-A742-4808-96FA-6F409E799937}';
    if (preg_match('/^\{?[A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}\}?$/', $guid)) {
      var_dump('ok');
    } else {
      var_dump('not ok');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider a database(MSSQL 2005) that consists of 100+ tables which have primary keys defined
I have a MySQL database which contains data i would like to populate into
I have a MySQL database which contains a table of users. The primary key
I have a web application that relies on a MySQL database, for which I
MS SQL Server database. I have this simple structure: (sorry about primary keys not
I have a normalized database and need to produce web based reports frequently that
I need some help I have been scouring the web and haven't been able
I currently have a MySQL database which I was hoping to use to store
I have a mysql database in which i am using auto_increment(integer), can you tell
I have a mysql database in which there is about hundreds of category for

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.