Results 1 to 5 of 5

Thread: mySQL error, wrong syntax?

  1. #1
    Join Date
    Aug 2006
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default mySQL error, wrong syntax?

    An error appears when I run the following mySQL statement..

    Code:
    CREATE TABLE `actions` (
      `id` int(10) unsigned NOT NULL auto_increment,
      `actionid` tinyint(3) unsigned NOT NULL default '0',
      `playerid` smallint(6) NOT NULL default '0',
      `time` datetime NOT NULL default '0000-00-00 00:00:00',
      `map` tinyint(3) unsigned NOT NULL default '0',
      `xpos` smallint(5) unsigned NOT NULL default '65535',
      `ypos` smallint(5) unsigned NOT NULL default '65535',
      `parameters` varchar(255) collate latin1_general_ci NOT NULL default '',
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
    and the error message..


    Code:
    #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 'collate latin1_general_ci NOT NULL default '',
      PRIMARY KEY
    MySQL version : 4.0.27-standard
    Help would be appreciated!
    Last edited by cursed; 01-11-2008 at 01:03 AM.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    If I'm right, this is funny.

    NOT NULL default '',
    Not null, yet you specify the default value IS null.
    Last edited by djr33; 01-11-2008 at 05:06 AM. Reason: apparently I can't spell today
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Aug 2006
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33 View Post
    If I'm write, this is funny.

    NOT NULL default '',
    Not null, yet you specify the default value IS null.
    Thanks for the reply.. however I'm getting the same error, except with the NULL.

    error is as follows:

    Code:
    #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 'collate latin1_general_ci NULL,
      PRIMARY KEY  (`id`)
    ) ENGIN

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Well, you can have it not null.

    See, NULL is a keyword that means "cannot be empty". If you specified it as "null" it would be always empty-- in other words, worthless. You DO want to store data. "NOT NULL" specifies that there must always be a value for it. Using '' means null, an empty string. The way to get around this is to actually specify a value, like 0, or 'new'. You could also just remove "NOT NULL", which would leave it as allowed to be null, and that's just fine. If so, you can probably remove the default '' as well, leaving that whole part of the command off.

    I'm not sure if default='' or default '' is the right syntax, so you might play with that too.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Works fine for me.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •