Error creating table

Discussion in 'MySQL' started by douffle, May 6, 2008.

  1. #1
    Hi,

    I 'm using MySQL5 and I am trying to set up a table through phpMyAdmin on my server. The code I am using is as follows:

    mysql_query("CREATE TABLE validate(
    id INT(4) NOT NULL AUTO_INCREMENT,
    PRIMARY KEY(id),
    url VARCHAR(128),
    flag INT(1) DEFAULT '0',
    email varchar(50)
    )") or die(mysql_error());

    I'm new to MySQL but the code looked OK to me, however I keep getting the following error:

    #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 'mysql_query("CREATE TABLE validate(
    id INT(4) NOT NULL AUTO_INCREMENT,
    PRIMARY' at line 1

    Obviously there is an error there that I am not seeing. Can anyone show me where it is?

    Thanks.
     
    douffle, May 6, 2008 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Try just this:

    
    CREATE TABLE validate(
    id INT(4) NOT NULL AUTO_INCREMENT,
    PRIMARY KEY(id),
    url VARCHAR(128),
    flag INT(1) DEFAULT '0',
    email varchar(50)
    );
    
    Code (markup):
    The mysql_query is specific to php. You need to use just the sql syntax when querying through phpmyadmin or any other command line interface.
     
    jestep, May 6, 2008 IP
  3. apmsolutions

    apmsolutions Peon

    Messages:
    66
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Like he said....the actual sql statement is fine. Just run that alone.
     
    apmsolutions, May 6, 2008 IP
  4. douffle

    douffle Member

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #4
    Worked perfectly!
    Thank you for your help. VERY much apprciated.
     
    douffle, May 6, 2008 IP