phpMyAdmin gives syntax error on 'perfect' table script

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Abby
Forum Newbie
Posts: 4
Joined: Tue May 13, 2003 9:19 pm
Location: Australia

phpMyAdmin gives syntax error on 'perfect' table script

Post by Abby »

This script is identical in syntax to other code that was succesfully entered into phpMyAdmin. I am puzzled because it should work. Could someone try it out for me? Cheers Abby

---------
CREATE TABLE ADDRESS
(
addressID INT(10) NOT NULL AUTO_INCREMENT,
addressType VARCHAR(8) NOT NULL,
street1 VARCHAR(50),
street2 VARCHAR(50,
town VARCHAR(50),
state CHAR(5),
postcode VARCHAR(10),
country VARCHAR(20) REFERENCES COUNTRY (country),
email VARCHAR(50),
url VARCHAR(50),
phone CHAR(15),
mobile CHAR(15),
fax CHAR(15),
PRIMARY KEY ('addressID')
);

-------------
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What exactly is the error?

Mac
Abby
Forum Newbie
Posts: 4
Joined: Tue May 13, 2003 9:19 pm
Location: Australia

Error message

Post by Abby »

This is the error message:

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 ' town VARCHAR( 50 ) , state CHAR( 5 ) , postcode VARCHAR( 10
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Possibly because there's a missing closing parenthesis on this line:

Code: Select all

street2 VARCHAR(50,
Mac
Abby
Forum Newbie
Posts: 4
Joined: Tue May 13, 2003 9:19 pm
Location: Australia

Error message

Post by Abby »

The missing parenthesis was a real booboo but it still returns the same error.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Maybe it's the smiley face in the middle of the code.


:wink: hehe~
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Think I've spotted it:

Code: Select all

PRIMARY KEY ('addressID')
should be either:

Code: Select all

PRIMARY KEY (`addressID`)
(using backticks instead of single quotes around the table name) or

Code: Select all

PRIMARY KEY (addressID)

(without any backticks)

Mac
Post Reply