Problem in creating a database

Discussion in 'MySQL' started by balaji153, Oct 8, 2008.

  1. #1
    i tried to create a table using this code"CREATE TABLE news(
    id INT NOT NULL AUTO_INCREMENT,
    title VARCHAR(50) NOT NULL,
    content TEXT NOT NULL,
    PRIMARY KEY(id)
    );
    "

    but i am getting error "no database selected "

    Can you help me how to select a database while creating a table?
     
    balaji153, Oct 8, 2008 IP
  2. max pain

    max pain Notable Member

    Messages:
    2,179
    Likes Received:
    521
    Best Answers:
    0
    Trophy Points:
    260
  3. crivion

    crivion Guest

    Best Answers:
    0
    #3
    can't u use phpmyadmin? if not before executing that query give a mysql_select_db("databasename");
     
    crivion, Oct 8, 2008 IP
  4. SEOpaw

    SEOpaw Peon

    Messages:
    437
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you must select an existing database or create new database before you can add or create new tables
     
    SEOpaw, Oct 8, 2008 IP
  5. VishalVasani

    VishalVasani Peon

    Messages:
    560
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hello,

    You have problem in Problem in creating a database or a Table news.
    Furthermore, provide details how u are creating.
    Using code in php or using any database tool such as phpmyadmin.
     
    VishalVasani, Oct 8, 2008 IP
  6. Mr_2

    Mr_2 Peon

    Messages:
    980
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #6
    if you have access in phpmyadmin go there and select a database and then run your query.
    that should work
     
    Mr_2, Oct 14, 2008 IP