Jump to content

Recommended Posts

Posted

Hi,

I'm setting up a table in a database for my site, and I'm getting a SQL error after entering this code into the query window:

 

>CREATE TABLE Sabre (

sabreName VARCHAR(20) NOT NULL,
realName VARCHAR(20),
age CHAR(2),
timezone VARCHAR(15),
country VARCHAR(20),
email VARCHAR(30),
AIM VARCHAR(25),
MSN VARCHAR(30),
ICQ VARCHAR(15),
sabreChar VARCHAR(12),
sabreCombat CHAR(3),
otherChar VARCHAR(12),
comment BLOB(500),
PRIMARY KEY (sabreName) 
)

 

I get the error:

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 '( 500  ) ,

PRIMARY  KEY ( sabreName )  )' at line 13

 

Any idea what I'm doing wrong?

 

~Noctorum

Posted

Also, make sure that your statement is ended with a semi-colon ( ; ).

It isn't in the code pasted above, so I didn't know if that was just a copy paste error, or if it was really missing in your statement.

Posted

Ok, I redid it and tried both of these:

 

>CREATE TABLE Sabre (

sabreName VARCHAR(20) NOT NULL,
realName VARCHAR(20),
age CHAR(2),
timezone VARCHAR(15),
country VARCHAR(20),
email VARCHAR(30),
AIM VARCHAR(25),
MSN VARCHAR(30),
ICQ VARCHAR(15),
sabreChar VARCHAR(12),
sabreCombat CHAR(3),
otherChar VARCHAR(12),
extra BLOB(500),
PRIMARY KEY (sabreName);
)

 

And

 

>CREATE TABLE Sabre (

sabreName VARCHAR(20) NOT NULL,
realName VARCHAR(20),
age CHAR(2),
timezone VARCHAR(15),
country VARCHAR(20),
email VARCHAR(30),
AIM VARCHAR(25),
MSN VARCHAR(30),
ICQ VARCHAR(15),
sabreChar VARCHAR(12),
sabreCombat CHAR(3),
otherChar VARCHAR(12),
extra BLOB(500),
PRIMARY KEY (sabreName)
);

 

Neither of those worked. It won't work putting the table in which MySQL-Front, either.

 

:wub: :D

 

I'm not quite sure what could be going wrong, it's giving me the same error.

Posted

>CREATE TABLE Sabre
(sabreName VARCHAR(20) PRIMARY KEY,
realName VARCHAR(20),
age CHAR(2),
timezone VARCHAR(15),
country VARCHAR(20),
email VARCHAR(30),
AIM VARCHAR(25),
MSN VARCHAR(30),
ICQ VARCHAR(15),
sabreChar VARCHAR(12),
sabreCombat CHAR(3),
otherChar VARCHAR(12),
extra BLOB(500),

);

 

Try that instead. I think having two distinct lines for sabreName may have been fouling it up. A primary key cannot be null anyway, so the two instructions were redundant.

Posted

Using that code, I get

 

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 '(500), )' at line 1

 

It seems to have an issue with

>extra BLOB(500),

 

I tried it with text also, no success. If I remove it, I don't get an error. I can do without it for the time being, but I'm still curious as to what was wrong with it :/

Posted

Hang tight and I'll manually create the table and export the SQL results.

 

Which begs the question, why not just build the table through the nice pretty phpMyAdmin interface in the first place?

Posted

Blob is binary so this works just dandy (remove the "(500)" from the 'extra' field):

 

>CREATE TABLE Sabre(
sabreName VARCHAR( 20 ) PRIMARY KEY ,
realName VARCHAR( 20 ) ,
age CHAR( 2 ) ,
timezone VARCHAR( 15 ) ,
country VARCHAR( 20 ) ,
email VARCHAR( 30 ) ,
AIM VARCHAR( 25 ) ,
MSN VARCHAR( 30 ) ,
ICQ VARCHAR( 15 ) ,
sabreChar VARCHAR( 12 ) ,
sabreCombat CHAR( 3 ) ,
otherChar VARCHAR( 12 ) ,
extra BLOB
);

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...