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..
Are you looking for a composite primary key? If so this is the code that will fix your error.
If not you just want a primary key – the AUTO_INCREMENT flag is for INT type only.
Or possibly you just need the UNIQUE constraint eg.