Closed Thread
Results 1 to 2 of 2

Thread: Help with SQL Query..

  1. #1
    Derek is offline Community Support Force Derek is a splendid one to beholdDerek is a splendid one to behold
    Join Date
    May 2005
    Location
    cossacks
    Posts
    6,354

    Help with SQL Query..

    I am trying to install pastebin and when I run this query I get this error



    SCRIPTL

    PHP Code:
    CREATE TABLE `pastebin` (
          `
    pidint(11NOT NULL auto_increment,
          `
    postervarchar(16) default NULL,
          `
    posteddatetime default NULL,
          `
    codetext,
          `
    parent_pidint(11) default '0',
          `
    formatvarchar(16) default NULL,
          `
    codefmtmediumtext,
          `
    codecsstext,
          `
    domainvarchar(255) default '',
          `
    expiresDATETIME,
          `
    expiry_flagENUM('d','m''f'NOT NULL DEFAULT 'm',
          
          
    PRIMARY KEY  (`pid`),
          
    KEY `domain` (`domain`),
          
    KEY `parent_pid`,
          
    KEY `expires`
        );

    create table recent
    (
        
    domain varchar(255),
        
    pid int not null,
        
    seq_no int not null,
        
        
    primary key(domain,seq_no)
    ); 

    ERRO:
    Error

    SQL query:
    CREATE TABLE `pastebin` ( `pid` int( 11 ) NOT NULL AUTO_INCREMENT ,
    `poster` varchar( 16 ) default NULL ,
    `posted` datetime default NULL ,
    `code` text,
    `parent_pid` int( 11 ) default '0',
    `format` varchar( 16 ) default NULL ,
    `codefmt` mediumtext,
    `codecss` text,
    `domain` varchar( 255 ) default '',
    `expires` DATETIME,
    `expiry_flag` ENUM( 'd', 'm', 'f' ) NOT NULL DEFAULT 'm',
    PRIMARY KEY ( `pid` ) ,
    KEY `domain` ( `domain` ) ,
    KEY `parent_pid` ,
    KEY `expires`
    );


    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 '
    KEY `expires`
    )' at line 16



    Will pay 50 points.
    Last edited by Derek; 08-02-2008 at 07:14 PM.

  2. #2
    LHVWB's Avatar
    LHVWB is offline Lord Of The Keys LHVWB is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Australia
    Posts
    1,308

    Re: Help with SQL Query..

    You need to have brackets around the KEY parts.

    Eg:
    KEY (`parent_pid`),
    KEY (`expires`)

    Here is the fixed and working sql query.
    Code:
    CREATE TABLE `pastebin` (
          `pid` int(11) NOT NULL auto_increment,
          `poster` varchar(16) default NULL,
          `posted` datetime default NULL,
          `code` text,
          `parent_pid` int(11) default '0',
          `format` varchar(16) default NULL,
          `codefmt` mediumtext,
          `codecss` text,
          `domain` varchar(255) default '',
          `expires` DATETIME,
          `expiry_flag` ENUM('d','m', 'f') NOT NULL DEFAULT 'm',
          
          PRIMARY KEY  (`pid`),
          KEY `domain` (`domain`),
          KEY (`parent_pid`),
          KEY (`expires`)
        );
    
    create table recent
    (
        domain varchar(255),
        pid int not null,
        seq_no int not null,
        
        primary key(domain,seq_no)
    );

Closed Thread

Similar Threads

  1. What's wrong with this SQL Query?
    By Derek in forum The Marketplace
    Replies: 3
    Last Post: 07-23-2008, 10:00 PM
  2. Problems with SQL query
    By anilson1 in forum Free Hosting
    Replies: 3
    Last Post: 04-28-2008, 10:55 PM
  3. anilson1 Problems with SQL query
    By mattura in forum Free Hosting
    Replies: 1
    Last Post: 04-28-2008, 11:48 AM
  4. [BEG] How to run a SQL query in phpMyAdmin
    By Brandon in forum Tutorials
    Replies: 0
    Last Post: 04-14-2007, 09:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers