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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:16:20+00:00 2026-05-26T12:16:20+00:00

Firstly, by using Primary key am I applying the UNIQUE constraint properly? <?php //

  • 0

Firstly, by using Primary key am I applying the UNIQUE constraint properly?

<?php
// Make a MySQL Connection
mysql_connect("localhost", "oassda", "oas53a") or die(mysql_error());
mysql_select_db("o345ja") or die(mysql_error());

// Create a MySQL table in the selected database
mysql_query("CREATE TABLE PersonInfo(
Email VARCHAR(45) NOT NULL AUTO_INCREMENT, 
PRIMARY KEY(Email),
 PNumber VARCHAR(45))")
 or die(mysql_error());  

echo "Table Created!";

?>

I am trying to make it so Email and PNumber cannot have duplicate rows inserted..But the error I get is “Incorrect column specifier for column ‘Email'” apparently this is a bug due to AUTO_INCREMENT only working on INT types….Any idea what to do to make these 2 columns without duplicates ? sorry I am not experienced with MySQL too much as I did it very long time ago and new bugs have developed since then..

  • 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-05-26T12:16:21+00:00Added an answer on May 26, 2026 at 12:16 pm

    Are you looking for a composite primary key? If so this is the code that will fix your error.

    mysql_query("CREATE TABLE PersonInfo(
    Email VARCHAR(45) NOT NULL, 
     PNumber VARCHAR(45),
    PRIMARY KEY(Email,PNumber))")
     or die(mysql_error());
    

    If not you just want a primary key – the AUTO_INCREMENT flag is for INT type only.

    mysql_query("CREATE TABLE PersonInfo(
        Email VARCHAR(45) NOT NULL, 
         PNumber VARCHAR(45),
        PRIMARY KEY(Email))")
         or die(mysql_error());
    

    Or possibly you just need the UNIQUE constraint eg.

    mysql_query("CREATE TABLE PersonInfo(
            Email VARCHAR(45) NOT NULL, 
             PNumber VARCHAR(45),
            PRIMARY KEY(Email),
            UNIQUE(PNumber))")
             or die(mysql_error());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly, if it is relevant, I'm using MySQL, though I assume a solution would
I have a modeling question related to profiles. Firstly, I have looked into using
Firstly, I know I should be using proper Threading techniques (Threadpool, BeginInvoke, etc.) to
Firstly, I'm not asking how to perform a multi-file upload using CodeIgniter, but rather
Firstly, this DB question could be a bit DB agnostic, but I am using
I am writing a graphical application using SWT. Firstly I created a shell with
Hi i have a couple of question about using named pipes. Firstly, when trying
We serialize/deserialize XML using XStream... and just got an OutOfMemory exception. Firstly I don't
My question is two fold, firstly, is it possible to create a foreign key,in
Firstly - Z is Up in this problem. Context: Top down 2D Game using

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.