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?

Link to comment
Share on other sites

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`);

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.