Jump to content

[SOLVED] a new auto incriment column in mysql, and another mydql question


blueman378

Recommended Posts

hi guys i have a table that looks like this:

CREATE TABLE `games` (
  `gSwfFile` varchar(100) NOT NULL,
  `gName` varchar(100) NOT NULL,
  `gThumb` varchar(100) NOT NULL,
  `gDescription` varchar(100) NOT NULL,
  `gplays` smallint(5) unsigned NOT NULL default '0',
  `RId` smallint(5) unsigned NOT NULL default '0',
  `category` varchar(100) NOT NULL,
  `keyword` varchar(100) NOT NULL,
  UNIQUE KEY `gName` (`gName`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

now what i want is to add in a column called RId and have it auto incriment,

however when i try i get..

#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key 

 

any ideas what i have to do?

hmm i deleted that and tried to set that column as the unique key and get:

SQL query:

ALTER TABLE `games` ADD UNIQUE (
`RId`
)

MySQL said: Documentation
#1062 - Duplicate entry '0' for key 1 

???

Create it with

CREATE TABLE `games` (
  `gSwfFile` varchar(100) NOT NULL,
  `gName` varchar(100) NOT NULL,
  `gThumb` varchar(100) NOT NULL,
  `gDescription` varchar(100) NOT NULL,
  `gplays` smallint(5) unsigned NOT NULL default '0',
  `RId` smallint(5) unsigned NOT NULL auto_increment primary key,
  `category` varchar(100) NOT NULL,
  `keyword` varchar(100) NOT NULL,
  UNIQUE KEY `gName` (`gName`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

or mod existing table with

ALTER TABLE `games` MODIFY COLUMN `RId` INTEGER NOT NULL AUTO_INCREMENT,
ADD PRIMARY KEY(`RId`);

well i have already created this topic so i might as well ask here,

i am trying out a script and i now get this error:

Fatal error: Function name must be a string in C:\wamp\www\admin\gameinstaller.php on line 173

but line 173 is

$sql("INSERT INTO ".games."

well i have already created this topic so i might as well ask here,

i am trying out a script and i now get this error:

Fatal error: Function name must be a string in C:\wamp\www\admin\gameinstaller.php on line 173

but line 173 is

$sql("INSERT INTO ".games."

 

You need

 

$sql = "INSERT INTO ".games." // etc

 

PhREEEk

i didnt even see that there was no primary_key and auto_increment my example was using the update statement as a secound increment dam dam dam....

 

what would we ever do without barand (happy xmas barand and happy new year)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.