Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Web Coding

Reply
 
LinkBack Thread Tools
Old 01-30-08   #1 (permalink)
Audiophile
 
F3t1sh's Avatar
 
intel ati

Join Date: Oct 2006
Location: Gatineau, Quebec
Posts: 805
Blog Entries: 4

Rep: 36 F3t1sh is acknowledged by some
Unique Rep: 26
Folding Team Rank: 1084
Hardware Reviews: 1
Trader Rating: 0
Default MySQL error

I have a table with a column called ID which auto increments when i add values but the problem is when I go to delete a row before another row and I try to add another value, I get:
"Error: Duplicate entry '2' for key 1"
So is there a way to make that column auto update to "1" if it starts at "2" and if there are values (doesn't go up like 1, 2, 3, 4, etc) missing?
__________________


My Votes



31D8M4a1r1k

System: lolz
CPU
Q6600 GO @ 3.6 1.44v (450*8)
Motherboard
Abit IP35 Pro
Memory
Crucial Ballistix 4x1GB
Graphics Card
HIS Radeon 3870x2
Hard Drive
RAID0 - Seagate Barracuda 160GB
Sound Card
AuzenTech Auzen Prelude
Power Supply
GameXStream 700W
Case
Ultra Aluminus
CPU cooling
Xigmatek S1283 w/Backplate mod
OS
Vista HP 64Bit
Monitor
Samsung 225BW
F3t1sh is online now I fold for Overclock.net F3t1sh's Gallery   Reply With Quote
Old 01-30-08   #2 (permalink)
AMD Overclocker
 
Starholdest's Avatar
 
amd nvidia

Join Date: Mar 2007
Location: █♣█
Posts: 925
Blog Entries: 1

Rep: 43 Starholdest is acknowledged by some
Unique Rep: 38
Hardware Reviews: 1
Trader Rating: 0
Default

I don't think there is. You have your ID row setup like this right:
Attached Thumbnails
mysql-error-mysql.png  
__________________

My s939 rig build log thread - 4600+ @ 2.8Ghz stable


Aumotocnic "An unfortunate member of the overclock.net insomnia club"

Quebec Overclockers - 8019 in 3dMark06

s939 Manny 4600+ @ 2809Mhz @ 1.425V (9 hours Orthos blend test stable - 24/7 Usage) - http://valid.x86-secret.com/show_oc.php?id=289741
@ 2945Mhz @ 1.45V (YAY! - Not stable, doh!) - http://valid.x86-secret.com/show_oc.php?id=276669

System: Beast from the East
CPU
AMD x2 4600+ @ 2.8Ghz
Motherboard
Asus A8N-SLI SE
Memory
2GB Kingston Value DDR400
Graphics Card
Asus 8800GTS 320MB
Hard Drive
80G Seagate SATA
Sound Card
SoundBlaster Audigy SE
Power Supply
Thermaltake Purepower 500W
Case
Antec 900 (modded)
CPU cooling
AS5 + Zalman CNPS9700 LED
GPU cooling
Stock
OS
Windows Vista Ultimate
Monitor
Samsung Syncmaster 730B (17" yay!)
Starholdest is offline Starholdest's Gallery   Reply With Quote
Old 01-30-08   #3 (permalink)
Database Developer
 
mirunit's Avatar
 
intel nvidia

Join Date: Dec 2004
Location: North Carolina
Posts: 720

Rep: 35 mirunit is acknowledged by some
Unique Rep: 32
Trader Rating: 0
Default

Set it as an Identity field. In MSSQL I know it is Identity(1,1)
__________________
A fan of anything which uses AES, .NET, Relational Databases, RAID arrays, water cooling, HSDPA, GPS, x64 or a BMW engine.

System: Rep My Thug
CPU
Intel Q6600 @ 3.6 ghz
Motherboard
EVGA 680i SLI 775 A1
Memory
2x2GB Corsair XMS2 @ 900 mhz
Graphics Card
2x 9800 GTX (SLI) + 7950 GT
Hard Drive
2x 7200RPM Raid0
Sound Card
Onboard 7.1 Realtek HD
Power Supply
750w Silverstone
Case
Black Dragon w/ Window
CPU cooling
DTEK Fuzion Block
GPU cooling
Stock
OS
Windows Vista x64 SP1
Monitor
2x 21" 16:10 LCD's
mirunit is offline   Reply With Quote
Old 01-31-08   #4 (permalink)
Performance...
 
linskingdom's Avatar
 
intel nvidia

Join Date: Jun 2007
Location: In Office
Posts: 8,718

Rep: 2148 linskingdom is a legendlinskingdom is a legendlinskingdom is a legendlinskingdom is a legendlinskingdom is a legendlinskingdom is a legendlinskingdom is a legendlinskingdom is a legendlinskingdom is a legendlinskingdom is a legendlinskingdom is a legend
Unique Rep: 930
Trader Rating: 3
Default

Make sure the column data type is INT, Select/set Identity property to "Yes". And default seek/increament will be 1/1.

System: QD65D45
CPU
65Q/D&45D
Motherboard
DFI/Asus/Gigabyte
linskingdom is online now Overclocked Account linskingdom's Gallery   Reply With Quote
Old 01-31-08   #5 (permalink)
Audiophile
 
F3t1sh's Avatar
 
intel ati

Join Date: Oct 2006
Location: Gatineau, Quebec
Posts: 805
Blog Entries: 4

Rep: 36 F3t1sh is acknowledged by some
Unique Rep: 26
Folding Team Rank: 1084
Hardware Reviews: 1
Trader Rating: 0
Default

Well considering i only have access to phpMyAdmin to work with, how can i do that with only:

Field Type Collation Attributes Null Default Extra Action
ID int(3) ----------------------------No--------- auto_increment

as options available. Anyone know how to do this, or is this done through a SQL Query or through the php
__________________


My Votes



31D8M4a1r1k

System: lolz
CPU
Q6600 GO @ 3.6 1.44v (450*8)
Motherboard
Abit IP35 Pro
Memory
Crucial Ballistix 4x1GB
Graphics Card
HIS Radeon 3870x2
Hard Drive
RAID0 - Seagate Barracuda 160GB
Sound Card
AuzenTech Auzen Prelude
Power Supply
GameXStream 700W
Case
Ultra Aluminus
CPU cooling
Xigmatek S1283 w/Backplate mod
OS
Vista HP 64Bit
Monitor
Samsung 225BW

Last edited by F3t1sh : 01-31-08 at 10:55 PM.
F3t1sh is online now I fold for Overclock.net F3t1sh's Gallery   Reply With Quote
Old 01-31-08   #6 (permalink)
Audiophile
 
F3t1sh's Avatar
 
intel ati

Join Date: Oct 2006
Location: Gatineau, Quebec
Posts: 805
Blog Entries: 4

Rep: 36 F3t1sh is acknowledged by some
Unique Rep: 26
Folding Team Rank: 1084
Hardware Reviews: 1
Trader Rating: 0
Default

would my code be something like:

CREATE TABLE room
(
ID INT(1,1) NOT NULL AUTO_INCREMENT,
)

even then it doesnt work
__________________


My Votes



31D8M4a1r1k

System: lolz
CPU
Q6600 GO @ 3.6 1.44v (450*8)
Motherboard
Abit IP35 Pro
Memory
Crucial Ballistix 4x1GB
Graphics Card
HIS Radeon 3870x2
Hard Drive
RAID0 - Seagate Barracuda 160GB
Sound Card
AuzenTech Auzen Prelude
Power Supply
GameXStream 700W
Case
Ultra Aluminus
CPU cooling
Xigmatek S1283 w/Backplate mod
OS
Vista HP 64Bit
Monitor
Samsung 225BW
F3t1sh is online now I fold for Overclock.net F3t1sh's Gallery   Reply With Quote
Old 02-01-08   #7 (permalink)
AMD Overclocker
 
Starholdest's Avatar
 
amd nvidia

Join Date: Mar 2007
Location: █♣█
Posts: 925
Blog Entries: 1

Rep: 43 Starholdest is acknowledged by some
Unique Rep: 38
Hardware Reviews: 1
Trader Rating: 0
Default

Is it set as the primary key?
__________________

My s939 rig build log thread - 4600+ @ 2.8Ghz stable


Aumotocnic "An unfortunate member of the overclock.net insomnia club"

Quebec Overclockers - 8019 in 3dMark06

s939 Manny 4600+ @ 2809Mhz @ 1.425V (9 hours Orthos blend test stable - 24/7 Usage) - http://valid.x86-secret.com/show_oc.php?id=289741
@ 2945Mhz @ 1.45V (YAY! - Not stable, doh!) - http://valid.x86-secret.com/show_oc.php?id=276669

System: Beast from the East
CPU
AMD x2 4600+ @ 2.8Ghz
Motherboard
Asus A8N-SLI SE
Memory
2GB Kingston Value DDR400
Graphics Card
Asus 8800GTS 320MB
Hard Drive
80G Seagate SATA
Sound Card
SoundBlaster Audigy SE
Power Supply
Thermaltake Purepower 500W
Case
Antec 900 (modded)
CPU cooling
AS5 + Zalman CNPS9700 LED
GPU cooling
Stock
OS
Windows Vista Ultimate
Monitor
Samsung Syncmaster 730B (17" yay!)
Starholdest is offline Starholdest's Gallery   Reply With Quote
Old 02-01-08   #8 (permalink)
Database Developer
 
e_dogg's Avatar
 
intel nvidia

Join Date: Feb 2007
Location: Ventura, CA
Posts: 1,202

Rep: 144 e_dogg is acknowledged by manye_dogg is acknowledged by many
Unique Rep: 122
Trader Rating: 7
Default

Quote:
Originally Posted by F3t1sh View Post
would my code be something like:

CREATE TABLE room
(
ID INT(1,1) NOT NULL AUTO_INCREMENT,
)

even then it doesnt work
You'll need to set the ID column as identitiy as well. I can't remember what the exact syntax for that is in mySQL but I'm pretty sure that if you're creating the table it would be something like:

Code:
CREATE TABLE room
(
ID identity INT(1,1) NOT NULL AUTO_INCREMENT,
)
__________________
Club 0pera VIP Member

0pera 9.51
0pera Mini
IE 6 or 7 when Opera don't work

System: New Hotness
CPU
E6420 @ 2.8
Motherboard
Asus P5B-Plus
Memory
4x1gb G.Skill HZ @ 4-4-4-12
Graphics Card
Evga 8800GTS 320mb
Hard Drive
250gb + 750gb Seagate 7200.10 SATA
Power Supply
Rosewill 550w
Case
Coolermaster CM-690
CPU cooling
Zalman 9500AT
OS
Vista Ultimate x64
Monitor
Viewsonic VP171s
e_dogg is offline   Reply With Quote
Old 02-03-08   #9 (permalink)
Audiophile
 
F3t1sh's Avatar
 
intel ati

Join Date: Oct 2006
Location: Gatineau, Quebec
Posts: 805
Blog Entries: 4

Rep: 36 F3t1sh is acknowledged by some
Unique Rep: 26
Folding Team Rank: 1084
Hardware Reviews: 1
Trader Rating: 0
Default

Quote:
Originally Posted by Starholdest View Post
Is it set as the primary key?
Yes it is and still doesn't work
__________________


My Votes



31D8M4a1r1k

System: lolz
CPU
Q6600 GO @ 3.6 1.44v (450*8)
Motherboard
Abit IP35 Pro
Memory
Crucial Ballistix 4x1GB
Graphics Card
HIS Radeon 3870x2
Hard Drive
RAID0 - Seagate Barracuda 160GB
Sound Card
AuzenTech Auzen Prelude
Power Supply
GameXStream 700W
Case
Ultra Aluminus
CPU cooling
Xigmatek S1283 w/Backplate mod
OS
Vista HP 64Bit
Monitor
Samsung 225BW
F3t1sh is online now I fold for Overclock.net F3t1sh's Gallery   Reply With Quote
Old 02-03-08   #10 (permalink)
Audiophile
 
F3t1sh's Avatar
 
intel ati

Join Date: Oct 2006
Location: Gatineau, Quebec
Posts: 805
Blog Entries: 4

Rep: 36 F3t1sh is acknowledged by some
Unique Rep: 26
Folding Team Rank: 1084
Hardware Reviews: 1
Trader Rating: 0
Default

Quote:
Originally Posted by e_dogg View Post
Code:
CREATE TABLE room
(
ID identity INT(1,1) NOT NULL AUTO_INCREMENT,
)
I get:


Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identity INT(1,1) NOT NULL AUTO_INCREMENT,
)' at line 3
(0 ms taken)


I guess my real problem is reseting the ID row and making it auto number itself again when i delete something.
__________________


My Votes



31D8M4a1r1k

System: lolz
CPU
Q6600 GO @ 3.6 1.44v (450*8)
Motherboard
Abit IP35 Pro
Memory
Crucial Ballistix 4x1GB
Graphics Card
HIS Radeon 3870x2
Hard Drive
RAID0 - Seagate Barracuda 160GB
Sound Card
AuzenTech Auzen Prelude
Power Supply
GameXStream 700W
Case
Ultra Aluminus
CPU cooling
Xigmatek S1283 w/Backplate mod
OS
Vista HP 64Bit
Monitor
Samsung 225BW
F3t1sh is online now I fold for Overclock.net F3t1sh's Gallery   Reply With Quote
Reply



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



All times are GMT -4. The time now is 06:42 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.22204 seconds with 10 queries