Jump to content

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


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)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.