SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict Banana Man's Avatar
    Join Date
    Dec 2005
    Posts
    391
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    if table doesnt exist create table?????

    Hey,

    I need a script to check to see if a table already exists in the mysql database and if it doesnt to create the new table. Can someone tell me the code i should be doing to do this.

    Thanks

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe:
    Code:
    mysql_query("CREATE TABLE IF NOT EXISTS tablename (
      id INT NOT NULL AUTO_INCREMENT,
      fname varchar(20),
      lname varchar(20),
      primary key (id))
    ");

  3. #3
    SitePoint Addict Banana Man's Avatar
    Join Date
    Dec 2005
    Posts
    391
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks m8, that got it sorted


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
  •