Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Help needed understanding MySQL Key types
Old 10-15-2007, 06:50 PM Help needed understanding MySQL Key types
Junior Talker

Posts: 1
Name: Mark
Trades: 0
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.
lanrat is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-15-2007, 06:58 PM Re: Help needed understanding MySQL Key types
247SiteAlert's Avatar
Average Talker

Posts: 28
Trades: 0
Drop the Unique id index and just let it be the Primary index. Your warning says the field id cannot be both.
__________________
Free Website Uptime Monitoring

Please login or register to view this content. Registration is FREE
247SiteAlert is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help needed understanding MySQL Key types
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14500 seconds with 12 queries