TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Display Modes
Old 02-05-2008, 11:01 PM   #1 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 254
Thanks: 39
sarmenhb is on a distinguished road
Default importing table and getting error. need help

hi

this is the table structure that i'm querying
and the bug that i'm getting is:

SQL Error: Incorrect table definition; There can only be one auto column and it must be defined as a key

how can i fix it, anyone see the problem?
thanks

Code:
CREATE TABLE `prospects` (
  `id`                          varchar(36) NOT NULL,
  `tracker_key`                 int AUTO_INCREMENT NOT NULL,
  `deleted`                     tinyint(1) DEFAULT '0',
  `date_entered`                datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `date_modified`               datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `modified_user_id`            varchar(36),
  `assigned_user_id`            varchar(36),
  `created_by`                  varchar(36),
  `salutation`                  varchar(5),
  `first_name`                  varchar(100),
  `last_name`                   varchar(100),
  `title`                       varchar(25),
  `department`                  varchar(255),
  `birthdate`                   date,
  `do_not_call`                 char(3) DEFAULT '0',
  `phone_home`                  varchar(25),
  `phone_mobile`                varchar(25),
  `phone_work`                  varchar(25),
  `phone_other`                 varchar(25),
  `phone_fax`                   varchar(25),
  `email1`                      varchar(100),
  `email2`                      varchar(100),
  `assistant`                   varchar(75),
  `assistant_phone`             varchar(25),
  `email_opt_out`               char(3) DEFAULT '0',
  `primary_address_street`      varchar(150),
  `primary_address_city`        varchar(100),
  `primary_address_state`       varchar(100),
  `primary_address_postalcode`  varchar(20),
  `primary_address_country`     varchar(100),
  `alt_address_street`          varchar(150),
  `alt_address_city`            varchar(100),
  `alt_address_state`           varchar(100),
  `alt_address_postalcode`      varchar(20),
  `alt_address_country`         varchar(100),
  `description`                 longtext,
  `invalid_email`               tinyint(1) DEFAULT '0',
  `lead_id`                     varchar(36),
  `account_name`                varchar(150),
  /* Keys */
  PRIMARY KEY (`id`)
) 
TYPE = MyISAM;

CREATE INDEX `idx_prospecs_del_last`
  ON `prospects`
  (`last_name`, `deleted`);

CREATE INDEX `idx_prospects_last_first`
  ON `prospects`
  (`last_name`, `first_name`, `deleted`);

CREATE INDEX `prospect_auto_tracker_key`
  ON `prospects`
  (`tracker_key`);
__________________
http://www.sarmenhb.com
Send a message via AIM to sarmenhb Send a message via MSN to sarmenhb Send a message via Yahoo to sarmenhb Send a message via Skype™ to sarmenhb
sarmenhb is offline  
Reply With Quote
Old 02-06-2008, 10:57 AM   #2 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 265
Thanks: 2
TlcAndres is on a distinguished road
Default

If I'm not mistaken, the field that is to be incremented has to be the primary key
TlcAndres is offline  
Reply With Quote
Old 02-06-2008, 11:06 AM   #3 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 818
Thanks: 163
Orc is on a distinguished road
Default

Hell yeah it has to be a primary key, that's probably the only reason, there are two ways to do this:

1.
sql Code:
CREATE TABLE `blah` (
       `id` int(5) NOT NULL AUTO_INCREMENT PRIMARY KEY
);

2. [highlight=sql]
CREATE TABLE `bleh2` (
`id` int(5) not null auto_increment,
KEY `id` ( `id` ) // OR this
PRIMARY KEY (`id`)
);
[/hightlight]

Your choice, they all work the same way.


Edit: What the crap?
__________________
Wax on, Wax off
Orc is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

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


All times are GMT. The time now is 05:52 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0