Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 743 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

SQL Table error

Thread title: SQL Table error
Closed Thread    
    Thread tools Search this thread Display Modes  
10-20-2007, 11:43 PM
#1
Adam S. is offline Adam S.
Adam S.'s Avatar
Status: Senior Member
Join date: Aug 2006
Location: New Brunswick, Canada
Expertise: Coding / programming
Software: NotePad
 
Posts: 824
iTrader: 9 / 100%
 

Adam S. is on a distinguished road

  Old  SQL Table error

I'm working hard on a custom shopping cart system and all the tables have gone into the DB perfectly except for this one and I can't figure it out. Hopefully one of you kind lads can help out:

PHP Code:
CREATE TABLE order (
order_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
order_date VARCHAR(100),
order_lastupdate VARCHAR(100),
order_status VARCHAR(40),
order_first VARCHAR(20),
order_last VARCHAR(60),
order_email VARCHAR(255)
); 
Error:

MySQL said: Documentation
#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 'order (
order_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
order_date VARCHAR(1',
or' at line 1

10-20-2007, 11:53 PM
#2
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

I believe that "PRIMARY KEY" has to go at the end of the line. Also, I think you also have to add a number to INT such as INT(5). Haven't used SQL in a while though.

10-21-2007, 12:41 AM
#3
Lee_ is offline Lee_
Status: Member
Join date: Jun 2006
Location: UK
Expertise:
Software:
 
Posts: 184
iTrader: 2 / 100%
 

Lee_ is on a distinguished road

  Old

PHP Code:
CREATE TABLE `order` (
`
order_idINT(11NOT NULL AUTO_INCREMENT,
`
order_dateVARCHAR(100),
`
order_lastupdateVARCHAR(100),
`
order_statusVARCHAR(40),
`
order_firstVARCHAR(20),
`
order_lastVARCHAR(60),
`
order_emailVARCHAR(255),
PRIMARY KEY  (`order_id`)
); 
Edit: Tested that on my localhost and it works.

10-21-2007, 01:31 PM
#4
Adam S. is offline Adam S.
Adam S.'s Avatar
Status: Senior Member
Join date: Aug 2006
Location: New Brunswick, Canada
Expertise: Coding / programming
Software: NotePad
 
Posts: 824
iTrader: 9 / 100%
 

Adam S. is on a distinguished road

  Old

Works great, thanks for the help guys.

Closed Thread    


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

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed