Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Closed Thread
Old 07-02-2008, 09:06 PM mySQL error #1064
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 679
Name: Lashtal
Trades: 0
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
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
View Public Profile
 
 
Register now for full access!
Old 07-03-2008, 05:21 AM Re: mySQL error #1064
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
View Public Profile Visit chrishirst's homepage!
 
Old 07-03-2008, 07:37 AM Re: mySQL error #1064
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 679
Name: Lashtal
Trades: 0
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.
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
View Public Profile
 
Old 07-03-2008, 05:45 PM Re: mySQL error #1064
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
View Public Profile Visit chrishirst's homepage!
 
Old 07-04-2008, 12:32 AM Re: mySQL error #1064
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 679
Name: Lashtal
Trades: 0
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.
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
View Public Profile
 
Old 07-04-2008, 12:58 AM Re: mySQL error #1064
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
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
View Public Profile
 
Old 07-04-2008, 05:55 AM Re: mySQL error #1064
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
View Public Profile Visit chrishirst's homepage!
 
Old 07-06-2008, 09:18 AM Re: mySQL error #1064
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 679
Name: Lashtal
Trades: 0
I just went to school, lol

Lot of info here for this beginner to digest.
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
View Public Profile
 
Old 07-06-2008, 02:57 PM Re: mySQL error #1064
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
People don't like nulls anymore? They're a valuable tool, and this is the right situation for a null value.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
View Public Profile Visit ForrestCroce's homepage!
 
Closed Thread     « Reply to mySQL error #1064
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
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.38197 seconds with 12 queries