mysql error

  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

Error

SQL-query :

PHP Code: [ Select ]
CREATE TABLE gs_admin(
 
 
 
ipaddress VARCHAR( 32 ) NOT NULL default '',
 
lastvisit VARCHAR( 255 ) NOT NULL default '',
 
username VARCHAR( 40 ) NOT NULL default '',
 
pass VARCHAR( 32 ) NOT NULL default '',
 
 
 
)
  1. CREATE TABLE gs_admin(
  2.  
  3.  
  4.  
  5. ipaddress VARCHAR( 32 ) NOT NULL default '',
  6.  
  7. lastvisit VARCHAR( 255 ) NOT NULL default '',
  8.  
  9. username VARCHAR( 40 ) NOT NULL default '',
  10.  
  11. pass VARCHAR( 32 ) NOT NULL default '',
  12.  
  13.  
  14.  
  15. )


MySQL said:


#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 ')' at line 5

---------------------------------------------------------
Whats the problem with the above?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Mr. Wiggles
  • Graduate
  • Graduate
  • Mr. Wiggles
  • Posts: 160
  • Loc: Brizzle

Post 3+ Months Ago

Doesn't one of these have to be a primary key?
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

PHP Code: [ Select ]
CREATE TABLE gs_admin(
 
 
 
ipaddress VARCHAR( 32 ) NOT NULL default '',
 
lastvisit VARCHAR( 255 ) NOT NULL default '',
 
username VARCHAR( 40 ) NOT NULL default '',
 
pass VARCHAR( 32 ) NOT NULL default '',
 
) ;
  1. CREATE TABLE gs_admin(
  2.  
  3.  
  4.  
  5. ipaddress VARCHAR( 32 ) NOT NULL default '',
  6.  
  7. lastvisit VARCHAR( 255 ) NOT NULL default '',
  8.  
  9. username VARCHAR( 40 ) NOT NULL default '',
  10.  
  11. pass VARCHAR( 32 ) NOT NULL default '',
  12.  
  13. ) ;



???


not really, because there is only one admin.
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

the problem was i added a , at the end .... forgot...

Let that be a note to everyone... do not leave a comma on the last line
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

what about this one:

PHP Code: [ Select ]
CREATE TABLE gs_news(
 
 
 
'id'MEDIUMINT( 64 ) NOT NULL AUTO_INCREMENT ,
 
`title` varchar( 64 ) NOT NULL ,
 
`introduction` varchar( 200 ) ,
 
`news` TEXT( 8000 ) NOT NULL ,
 
`datetime` Date / Time( 200 ) NOT NULL ,
 
`poster` varchar( 200 ) NOT NULL ,
 
PRIMARY KEY ( `id` )
 
)
  1. CREATE TABLE gs_news(
  2.  
  3.  
  4.  
  5. 'id'MEDIUMINT( 64 ) NOT NULL AUTO_INCREMENT ,
  6.  
  7. `title` varchar( 64 ) NOT NULL ,
  8.  
  9. `introduction` varchar( 200 ) ,
  10.  
  11. `news` TEXT( 8000 ) NOT NULL ,
  12.  
  13. `datetime` Date / Time( 200 ) NOT NULL ,
  14.  
  15. `poster` varchar( 200 ) NOT NULL ,
  16.  
  17. PRIMARY KEY ( `id` )
  18.  
  19. )
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

Yea thats pretty simple.
PHP Code: [ Select ]
CREATE TABLE gs_news(
 
 
 
`id` MEDIUMINT( 64 ) NOT NULL AUTO_INCREMENT ,
 
`title` varchar( 64 ) NOT NULL ,
 
`introduction` varchar( 200 ) ,
 
`news` TEXT NOT NULL ,
 
`datetime` DATE NOT NULL ,
 
`poster` varchar( 200 ) NOT NULL ,
 
PRIMARY KEY ( `id` )
 
)
  1. CREATE TABLE gs_news(
  2.  
  3.  
  4.  
  5. `id` MEDIUMINT( 64 ) NOT NULL AUTO_INCREMENT ,
  6.  
  7. `title` varchar( 64 ) NOT NULL ,
  8.  
  9. `introduction` varchar( 200 ) ,
  10.  
  11. `news` TEXT NOT NULL ,
  12.  
  13. `datetime` DATE NOT NULL ,
  14.  
  15. `poster` varchar( 200 ) NOT NULL ,
  16.  
  17. PRIMARY KEY ( `id` )
  18.  
  19. )

That should work for you.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

nem,

please use either the php or the code buttons when posting code. Thanks
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

Thanks, hoping someone was going to say something about that. :P
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Well, the interesting thing is that if the php code was used in the first place, nem may have noticed that the apostrophes used around id showed up in red indicating invalid syntax and would have probably corrected it on his own.

I like using HTML Kit for php and asp code because it has a similar color scheme making it much easier to spot syntax errors.
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

Yes, it is very good to use a program that has color highlighting to do code like ASP and PHP. I use Dev-PHP. It has highlighting for a few different languages.
If you want to try it out. It is free and is open source so you can probably do some modifications yourself if you want.
http://devphp.sourceforge.net/
  • Mr. Wiggles
  • Graduate
  • Graduate
  • Mr. Wiggles
  • Posts: 160
  • Loc: Brizzle

Post 3+ Months Ago

Scorpius wrote:
I use Dev-PHP/

SNAP!
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

Mr. Wiggles wrote:
SNAP!

SNAP! What?

Post Information

  • Total Posts in this topic: 12 posts
  • Users browsing this forum: No registered users and 127 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.