techPowerUp! Forums

Go Back   techPowerUp! Forums > Software > Programming & Webmastering

Reply
 
Thread Tools
Old Aug 12, 2008, 09:27 PM   #1
binsky3333
500 Posts
 
binsky3333's Avatar
 
Join Date: Jul 2007
Posts: 624 (0.29/day)
Thanks: 12
Thanked 22 Times in 17 Posts

System Specs

Mysql prob?

Ok whenever i try and create this table:
CREATE TABLE users (
id int(10) DEFAULT '0' NOT NULL auto_increment,
username varchar(40),
password varchar(50),
regdate varchar(20),
email varchar(100),
website varchar(150),
location varchar(150),
show_email int(2) DEFAULT '0',
last_login varchar(20),
PRIMARY KEY(id))

I always get an error saying:
MySQL said:

#1067 - Invalid default value for 'id'

I have no clue what that means, is there something wrong with my code?
__________________
Check out my FPS Engine
http://forums.techpowerup.com/showthread.php?t=88124

binsky3333 is offline  
Reply With Quote
Old Aug 12, 2008, 10:19 PM   #2
ZenZimZaliben
2000 Posts
 
ZenZimZaliben's Avatar
 
Join Date: Mar 2005
Location: USA
Posts: 2,103 (0.70/day)
Thanks: 131
Thanked 517 Times in 383 Posts
Send a message via MSN to ZenZimZaliben

System Specs

Easy enough...You're running a later version of MYSQL. Anything past 5.x you no longer need to set a default value for auto_increment. So just remove the default part where ever you have specified auto_increment.

You can alter your sql file as well to fix this. Open the sql file in your editor (vi)...and type in minus the double quote.

"s/\(.*\)DEFAULT '0'\(.*\)auto_increment/\1\2auto_increment/). " crud it made a smiley.

" : (s/\(.*\)DEFAULT '0'\(.*\)auto_increment/\1\2auto_increment/). " without the first space
__________________
i7 930 @ 4.2Ghz
GIGABYTE x58 UD7
Kingston HyperX T1 Series 12GB
GIGABYTE 7970 (1280/1800)
OCZ Vertex 2 100GB SSD & VelociRaptor 300GB

HEATWARE
ZenZimZaliben is offline  
Reply With Quote
Old Aug 12, 2008, 10:27 PM   #3
DanTheBanjoman
Seņor Moderator
 
DanTheBanjoman's Avatar
 
Join Date: May 2004
Location: Utrecht, Utrecht, The kingdom of the Netherlands
Posts: 8,498 (2.58/day)
Thanks: 41
Thanked 1,453 Times in 1,077 Posts
Send a message via ICQ to DanTheBanjoman Send a message via MSN to DanTheBanjoman

System Specs

Auto increment doesn't have a default. ie you can't default 0 since it's auto increment, it picks the number for you.
DanTheBanjoman is offline  
Reply With Quote
Old Aug 12, 2008, 10:32 PM   #4
ZenZimZaliben
2000 Posts
 
ZenZimZaliben's Avatar
 
Join Date: Mar 2005
Location: USA
Posts: 2,103 (0.70/day)
Thanks: 131
Thanked 517 Times in 383 Posts
Send a message via MSN to ZenZimZaliben

System Specs

Hmmm I think you just said what I did in 20 less words. Much better, good job.

Versions older then 5.x did use a default value for auto_increment. No need for it anymore, but check your version of mysql.
__________________
i7 930 @ 4.2Ghz
GIGABYTE x58 UD7
Kingston HyperX T1 Series 12GB
GIGABYTE 7970 (1280/1800)
OCZ Vertex 2 100GB SSD & VelociRaptor 300GB

HEATWARE
ZenZimZaliben is offline  
Reply With Quote
Old Aug 21, 2008, 08:33 AM   #5
blTb
200 Posts
 
blTb's Avatar
 
Join Date: May 2008
Location: Littleton,CO
Posts: 248 (0.14/day)
Thanks: 33
Thanked 22 Times in 13 Posts
Send a message via ICQ to blTb Send a message via MSN to blTb

System Specs

Code:
id int(10) DEFAULT '0' NOT NULL auto_increment,
There is one more mistake:
id is not NULL, but you're giving a default value = 0!
blTb is offline  
Reply With Quote
Old Aug 21, 2008, 08:50 AM   #6
W1zzard
Benevolent Dictator
 
W1zzard's Avatar
 
Join Date: May 2004
Location: Stuttgart, Germany
Posts: 13,773 (4.18/day)
Thanks: 184
Thanked 10,220 Times in 3,163 Posts
Send a message via ICQ to W1zzard Send a message via AIM to W1zzard Send a message via MSN to W1zzard

System Specs

install phpmyadmin to make such administrative tasks much easier
W1zzard is online now  
Reply With Quote
Reply


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sun Microsystems Announces MySQL 5.1 malware News 0 Apr 17, 2008 10:11 AM
Sun Acquires MySQL, Developer of the World's Most Popular Open Source Database malware News 5 Jan 16, 2008 08:25 PM
Favorite 3rd party software with MySQL MySQLGeek General Software 0 Dec 31, 2007 08:17 AM
Intresting ram prob.. Solaris17 Motherboards & Memory 4 Sep 2, 2007 02:29 AM
Over Heating Prob with ATI X850 XT 256MB Toastpcs Graphics Cards 8 Jul 28, 2006 09:45 PM


All times are GMT. The time now is 12:09 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
no new posts