Jump to content


Photo

auto increment


  • Please log in to reply
6 replies to this topic

#1 pokeronald

pokeronald
  • Members
  • PipPip
  • Member
  • 11 posts
  • LocationIn front of the comp - Australia

Posted 06 July 2003 - 11:09 AM

hi, i want like when sumbody signs up and the id number increase automatically. in the db, which type do i use? when i tried some of the options, there was an error :
www.unipets.net
[br]
[br]if($you die()){
[br]kill $me;
[br]} else {
[br]$you = stupid
[br]print "=P";
[br]}
[br]
[br]Error: $you = stupid =P.

#2 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 08 July 2003 - 06:55 AM

An example

Hope this helps

CREATE TABLE `emp` (`Id` bigint(20) NOT NULL auto_increment, `name` varchar(20) default NULL,`age` int(10) default NULL,`details` varchar(200) default NULL,PRIMARY KEY  (`Id`)  );

Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#3 pokeronald

pokeronald
  • Members
  • PipPip
  • Member
  • 11 posts
  • LocationIn front of the comp - Australia

Posted 08 July 2003 - 07:26 AM

error message:

\"Incorrect table definition; There can only be one auto column and it must be defined as a key\"

what does that mean?
www.unipets.net
[br]
[br]if($you die()){
[br]kill $me;
[br]} else {
[br]$you = stupid
[br]print "=P";
[br]}
[br]
[br]Error: $you = stupid =P.

#4 gizmola

gizmola
  • Administrators
  • Advanced Member
  • 4,664 posts
  • LocationLos Angeles, CA USA

Posted 08 July 2003 - 10:34 AM

error message:

\\\"Incorrect table definition; There can only be one auto column and it must be defined as a key\\\"

what does that mean?


It means that there can only be one auto_increment column per table, and that column must be a key for the table, usually the primary key.

#5 bAnthony

bAnthony
  • New Members
  • Pip
  • Newbie
  • 1 posts
  • LocationFlorida

Posted 08 July 2003 - 02:47 PM

are you using phpMyAdmin or just writing scripts?
<?php [br] [br]$sentence = "This is pointless"; [br] [br]$sentence = explode(" ", $sentence); [br] [br]foreach($sentence as $word ) { [br] [br]echo "$word "; [br] [br]} [br] [br]echo "uhm... that was stupid"; [br] [br]?>

#6 pokeronald

pokeronald
  • Members
  • PipPip
  • Member
  • 11 posts
  • LocationIn front of the comp - Australia

Posted 08 July 2003 - 11:11 PM

but there IS no auto_increment else in my table...

i\'m using phpadmin

then how do u define it as a key?
www.unipets.net
[br]
[br]if($you die()){
[br]kill $me;
[br]} else {
[br]$you = stupid
[br]print "=P";
[br]}
[br]
[br]Error: $you = stupid =P.

#7 gizmola

gizmola
  • Administrators
  • Advanced Member
  • 4,664 posts
  • LocationLos Angeles, CA USA

Posted 09 July 2003 - 06:04 AM

If the table already exists, you would need to use alter table.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users