Hi,
As a newbie I'm trying to work through a PHP/MySQL tutorial that uses a PHP script to create a table called "contacts".
The table is created just fine but I cannot add any data because there is a problem with the indexing that, as a newbie, further complicates me understanding this tutorial.
Could somebody explain/help me understand a) what is the author trying to achieve and b) what is the fix?
-------------
After creating the database using phpMyAdmin I ran the supplied PHP Script to create the TABLE:
<? include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="CREATE TABLE contacts (id int(6) NOT NULL auto_increment,first varchar(15) NOT NULL,last varchar(15) NOT NULL,phone varchar(20) NOT NULL,mobile varchar(20) NOT NULL,fax varchar(20) NOT NULL,email varchar(30) NOT NULL,web varchar(30) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))"; mysql_query($query); mysql_close(); echo "Database TABLE created"; ?> In the phpMyAdmin interface I now see the TABLE *BUT* in the Indexes section this warning appears:
KeyName Type Cardinality Action Field PRIMARY PRIMARY 0 edit/drop id id UNIQUE 0 edit/drop id id_2 INDEX 0 edit/drop id [WARNING: PRIMARY and INDEX keys should not both be set for column `id`] Any advice apprectiated thanks.
|