Reply
mySQL error #1064
Old 07-02-2008, 08:06 PM mySQL error #1064
Lashtal's Avatar
Ultra Talker

Posts: 309
Name: Lashtal
When I try to drop the following code (in bold) into mySQL, I keep getting error #1064

CREATE TABLE dataprofiles (
profilenumber char(25) DEFAULT 'profilenumber' NOT NULL,
AdHeadline char(35) DEFAULT 'AdHeadline' NOT NULL,
EmailAddress char(50) DEFAULT 'EmailAddress' NOT NULL,
TelephoneAreaCode char(3) DEFAULT 'TelephoneAreaCode' NOT NULL,
City char(50) DEFAULT 'City' NOT NULL,
StateProvince char(50) DEFAULT 'StateProvince' NOT NULL,
Zip char(6) DEFAULT 'Zip' NOT NULL,
Country char(50) DEFAULT 'Country' NOT NULL,
RelationshipPreference char(50) DEFAULT 'RelationshipPreference' NOT NULL,
SexualPreference char(50) DEFAULT 'SexualPreference' NOT NULL,
Username char(12) DEFAULT 'Username' NOT NULL,
Password char(12) DEFAULT 'Password' NOT NULL,
VerifyPassword char(12) DEFAULT 'VerifyPassword' NOT NULL,
SmokingPreference char(50) DEFAULT 'SmokingPreference' NOT NULL,
DrinkingPreference char(50) DEFAULT 'DrinkingPreference' NOT NULL,
MaritialStatus char(50) DEFAULT 'MaritialStatus' NOT NULL,
HaveChildren char(50) DEFAULT 'HaveChildren' NOT NULL,
BodyBuild char(50) DEFAULT 'BodyBuild' NOT NULL,
Height char(50) DEFAULT 'Height' NOT NULL,
Religion char(50) DEFAULT 'Religion' NOT NULL,
Race char(50) DEFAULT 'Race' NOT NULL,
AstrologicalSign char(50) DEFAULT 'AstrologicalSign' NOT NULL,
Age char(3) DEFAULT 'Age' NOT NULL,
Occupation char(50) DEFAULT 'Occupation' NOT NULL,
MiscComments char(250) DEFAULT 'MiscComments' NOT NULL,
PRIMARY KEY(Username,EmailAddress)
);

_________________________________________

Error messages:

#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 'TelephoneAreaCode char(3) DEFAULT 'TelephoneAreaCode' NOT NULL,' at line 1

#1064 - same error for 'VerifyPassword char(12) DEFAULT 'VerifyPassword' NOT NULL,'


What am I doing wrong with these lines? The other strings worked Just Fine
__________________
www.LuciferCosmetics.com
Lashtal is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-03-2008, 04:21 AM Re: mySQL error #1064
chrishirst's Avatar
Super Moderator

Posts: 13,574
Location: Blackpool. UK
It is my belief that "TelephoneAreaCode" has more than 3 letters in it

TelephoneAreaCode char(3) DEFAULT 'TelephoneAreaCode' NOT NULL,
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-03-2008, 06:37 AM Re: mySQL error #1064
Lashtal's Avatar
Ultra Talker

Posts: 309
Name: Lashtal
I just changed it to:

CREATE TABLE dataprofiles (
profilenumber char(25) DEFAULT 'profilenumber' NOT NULL,
AdHeadline char(35) DEFAULT 'AdHeadline' NOT NULL,
EmailAddress char(50) DEFAULT 'EmailAddress' NOT NULL,

TelephoneAreaCode char(17) DEFAULT 'TelephoneAreaCode' NOT NULL,

City char(50) DEFAULT 'City' NOT NULL,
StateProvince char(50) DEFAULT 'StateProvince' NOT NULL,
Zip char(6) DEFAULT 'Zip' NOT NULL,
Country char(50) DEFAULT 'Country' NOT NULL,
RelationshipPreference char(50) DEFAULT 'RelationshipPreference' NOT NULL,
SexualPreference char(50) DEFAULT 'SexualPreference' NOT NULL,
Username char(12) DEFAULT 'Username' NOT NULL,
Password char(12) DEFAULT 'Password' NOT NULL,

VerifyPassword char(14) DEFAULT 'VerifyPassword' NOT NULL,

SmokingPreference char(50) DEFAULT 'SmokingPreference' NOT NULL,
DrinkingPreference char(50) DEFAULT 'DrinkingPreference' NOT NULL,
MaritialStatus char(50) DEFAULT 'MaritialStatus' NOT NULL,
HaveChildren char(50) DEFAULT 'HaveChildren' NOT NULL,
BodyBuild char(50) DEFAULT 'BodyBuild' NOT NULL,
Height char(50) DEFAULT 'Height' NOT NULL,
Religion char(50) DEFAULT 'Religion' NOT NULL,
Race char(50) DEFAULT 'Race' NOT NULL,
AstrologicalSign char(50) DEFAULT 'AstrologicalSign' NOT NULL,
Age char(3) DEFAULT 'Age' NOT NULL,
Occupation char(50) DEFAULT 'Occupation' NOT NULL,
MiscComments char(250) DEFAULT 'MiscComments' NOT NULL,
PRIMARY KEY(Username,EmailAddress)
);
CREATE TABLE bookmarks (
Username char(12) DEFAULT 'Username' NOT NULL,
Bookmark char(12) DEFAULT 'Bookmark' NOT NULL,
mix char(25) DEFAULT 'mix' NOT NULL,
PRIMARY KEY(mix)
);
CREATE TABLE emails (
messagenumber char(25) DEFAULT 'messagenumber' NOT NULL,
Sender char(12) DEFAULT 'Sender' NOT NULL,
Recipient char(12) DEFAULT 'Recipient' NOT NULL,
Date char(25) DEFAULT 'Date' NOT NULL,
Subject char(75) DEFAULT 'Subject' NOT NULL,
Message char(250) DEFAULT 'Message' NOT NULL,
PRIMARY KEY(messagenumber)
);

________________________

And it worked. Thanks again C.C.
__________________
www.LuciferCosmetics.com
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 07-03-2008, 04:45 PM Re: mySQL error #1064
chrishirst's Avatar
Super Moderator

Posts: 13,574
Location: Blackpool. UK
I would seriously suggest that you rethink the datatypes and structure you are using, the way your tables are set means that you are setting yourself up for severe problems at some point in the future.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-03-2008, 11:32 PM Re: mySQL error #1064
Lashtal's Avatar
Ultra Talker

Posts: 309
Name: Lashtal
Are you talking security risks?

if so, I will bet you anything that you're right. I'm a beginner trying to learn PHP and MySQL with free scripts I found online with their GNU licenses.
__________________
www.LuciferCosmetics.com
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 07-03-2008, 11:58 PM Re: mySQL error #1064
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
Wireless Audio
Posts: 2,320
Name: Keith Marshall
Location: West Hartford, CT
He is talking about this (for example):

Code:
CREATE TABLE `dataprofiles` (
  `profilenumber` int(11) unsigned NOT NULL auto_increment,
  `AdHeadline` varchar(50) NOT NULL default '',
  `EmailAddress` varchar(50) NOT NULL default '',
  `TelephoneAreaCode` int(3) unsigned zerofill NOT NULL default '000',
  `City` varchar(50) NOT NULL default '',
  `StateProvince` varchar(50) NOT NULL default '',
  `Zip` int(5) unsigned zerofill NOT NULL default '00000',
  `Country` varchar(50) NOT NULL default 'Country',
  `RelationshipPreference` varchar(50) NOT NULL default 'RelationshipPreference',
  `SexualPreference` varchar(50) NOT NULL default 'SexualPreference',
  `Username` varchar(12) NOT NULL default 'Username',
  `Password` varchar(32) NOT NULL default 'Password',
  `SmokingPreference` tinyint(1) unsigned NOT NULL default '0',
  `DrinkingPreference` tinyint(1) unsigned NOT NULL default '0',
  `MaritialStatus` varchar(50) NOT NULL default 'MaritialStatus',
  `HaveChildren` tinyint(1) unsigned NOT NULL default '0',
  `BodyBuild` varchar(50) NOT NULL default 'BodyBuild',
  `Height` varchar(50) NOT NULL default 'Height',
  `Religion` varchar(50) NOT NULL default 'Religion',
  `Race` varchar(50) NOT NULL default 'Race',
  `AstrologicalSign` varchar(50) NOT NULL default 'AstrologicalSign',
  `Age` int(3) unsigned NOT NULL default '0',
  `Occupation` varchar(50) NOT NULL default 'Occupation',
  `MiscComments` text,
  PRIMARY KEY  (`profilenumber`)
) ENGINE=InnoDB ;
Changing the profilenumber to the primary auto increment int type

Changing number fields to integer types

Removing unneeded default values

Changing password field to 32 char firld so you can store a 32 bit hash of the password instead of the raw text string

Changing preferences fileds to a tinyint bool type (0=false and 1=true)

Changing comments into a text type to allow for larger data storage, and change to null type to save room if there are no additional comments
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 07-04-2008, 04:55 AM Re: mySQL error #1064
chrishirst's Avatar
Super Moderator

Posts: 13,574
Location: Blackpool. UK
Keith has it pegged right.

You appear to be setting the datatypes and field sizes to suit the NAME of the column. I would guess at the idea being, you can then use the default inserted value as a "prompt" for values that were missed off by the user, which is a rather poor way of handling user input.
It simply inflates the data storage unnecessarily AND gives a false sense of security when handling the data in the back end system.
Ok, you won't get any errors caused by trying to process a NULL value, BUT you should be learning to handle NULL values from the outset, because there will be instances in the future where values may well be NULL and you have no control over the database you are querying.
As Keith points out having NULL fields on some datatypes can be a huge saving on storage space.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-06-2008, 08:18 AM Re: mySQL error #1064
Lashtal's Avatar
Ultra Talker

Posts: 309
Name: Lashtal
I just went to school, lol

Lot of info here for this beginner to digest.
__________________
www.LuciferCosmetics.com
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 07-06-2008, 01:57 PM Re: mySQL error #1064
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,024
Name: Forrest Croce
Location: Seattle, WA
People don't like nulls anymore? They're a valuable tool, and this is the right situation for a null value.
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Reply     « Reply to mySQL error #1064
 

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.16260 seconds with 12 queries