NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page MYSQL error

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 12-30-2006, 08:52 PM THREAD STARTER               #1 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes

MYSQL error


hey
i am getting this error:
Code:
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 'CREATE TABLE `messages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`from` varchar' at line 7
for this MYSQL :
PHP Code:
CREATE TABLE `keys` (
`
user_idint(11NOT NULL AUTO_INCREMENT,
`
keyvarchar(32NOT NULL DEFAULT '',
PRIMARY KEY  (`user_id`)
ENGINE=MyISAM DEFAULT CHARSET=latin1

CREATE TABLE 
`messages` (
`
idint(11NOT NULL AUTO_INCREMENT,
`
fromvarchar(255NOT NULL DEFAULT '0',
`
tovarchar(255NOT NULL DEFAULT '0',
`
messagelongtext NOT NULL,
`
titlevarchar(255NOT NULL DEFAULT '',
????: NamePros.com http://www.namepros.com/programming/275052-mysql-error.html
`
timetimestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`
readint(1NOT NULL DEFAULT '0',
PRIMARY KEY  (`id`)
ENGINE=MyISAM DEFAULT CHARSET=latin1

CREATE TABLE 
`users` (
`
idint(11NOT NULL AUTO_INCREMENT,
`
usernamevarchar(255NOT NULL DEFAULT '',
`
passwordvarchar(32NOT NULL DEFAULT '',
`
namevarchar(255NOT NULL DEFAULT '',
`
emailvarchar(255NOT NULL DEFAULT '',
`
ipvarchar(255NOT NULL DEFAULT '',
`
adminint(1NOT NULL DEFAULT '0',
????: NamePros.com http://www.namepros.com/showthread.php?t=275052
PRIMARY KEY  (`id`)
ENGINE=MyISAM DEFAULT CHARSET=latin1 
can anyone help me out? thanks
unknowngiver is offline  
Old 12-31-2006, 06:59 AM   #2 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
if you are trying to execute all 3 together which it looks like you are you need to put a ; after each query:-

PHP Code:
 CREATE TABLE `keys` (
`
user_idint(11NOT NULL AUTO_INCREMENT,
`
keyvarchar(32NOT NULL DEFAULT '',
PRIMARY KEY  (`user_id`)
ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `messages` (
`
idint(11NOT NULL AUTO_INCREMENT,
????: NamePros.com http://www.namepros.com/showthread.php?t=275052
`
fromvarchar(255NOT NULL DEFAULT '0',
`
tovarchar(255NOT NULL DEFAULT '0',
`
messagelongtext NOT NULL,
`
titlevarchar(255NOT NULL DEFAULT '',
`
timetimestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`
readint(1NOT NULL DEFAULT '0',
PRIMARY KEY  (`id`)
ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `users` (
`
idint(11NOT NULL AUTO_INCREMENT,
`
usernamevarchar(255NOT NULL DEFAULT '',
`
passwordvarchar(32NOT NULL DEFAULT '',
????: NamePros.com http://www.namepros.com/showthread.php?t=275052
`
namevarchar(255NOT NULL DEFAULT '',
`
emailvarchar(255NOT NULL DEFAULT '',
`
ipvarchar(255NOT NULL DEFAULT '',
`
adminint(1NOT NULL DEFAULT '0',
PRIMARY KEY  (`id`)
ENGINE=MyISAM DEFAULT CHARSET=latin1 
This is so mysql can distinguish between each sql statement, if you do not do this it thinks it is just 1 statement.
Peter is offline  
Old 12-31-2006, 07:29 AM   #3 (permalink)
Domains my Dominion
 
sdsinc's Avatar
Join Date: Aug 2005
Location: Web 1.0
Posts: 9,552
sdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatness
 


Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV Animal Rescue Wildlife Breast Cancer Animal Rescue Wildlife
Originally Posted by unknowngiver
hey
i am getting this error:
Code:
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 'CREATE TABLE `messages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`from` varchar' at line 7

????: NamePros.com http://www.namepros.com/showthread.php?t=275052
FROM is a reserved keyword in SQL.
Avoid using reserved keywords in field names or expressions and you'll be fine
__________________
NameNewsletter.com - free lists of available domain names
ZoneFiles.net (beta) - ccTLD and gTLD droplists
sdsinc is offline  
Old 12-31-2006, 10:29 AM   #4 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
Originally Posted by sdsinc

????: NamePros.com http://www.namepros.com/showthread.php?t=275052
FROM is a reserved keyword in SQL.
Avoid using reserved keywords in field names or expressions and you'll be fine
It isn't that causing the problem. Run it through mysql and you will see they work when you do them separately but when together it fails because of the missing ;

The following is taken from THIS page from the mysql manual:-

Quote:
A common problem stems from trying to use an identifier such as a table or column name that is a reserved word such as SELECT or the name of a built-in MySQL data type or function such as TIMESTAMP or GROUP.

Reserved words are permitted as identifiers if you quote them as described in Section 9.2, “Database, Table, Index, Column, and Alias Names”
In other words if you use the ticks around the field name as the op has already done.
Last edited by filth@flexiwebhost; 12-31-2006 at 10:38 AM.
Peter is offline  
Old 12-31-2006, 08:40 PM THREAD STARTER               #5 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
yup i ran it seprately and worked fine thanks
unknowngiver is offline  
Closed Thread


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


Liquid Web Smart Servers  
All times are GMT -7. The time now is 07:38 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger