Results 1 to 2 of 2

Thread: Creating Multiple SQL Tables (in php)

  1. #1
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Creating Multiple SQL Tables (in php)

    I am trying to make a script that will allow me to create multiple sql tables through one query in php. Here is what I was trying to use:
    PHP Code:
    mysql_query("
    CREATE TABLE `admins` ( 
        `id` tinyint(4) NOT NULL auto_increment,
        `date` varchar(20) NOT NULL,
        `username` varchar(32) NOT NULL,
        `password` varchar(32) NOT NULL,
        `email` varchar(100) NOT NULL,
        PRIMARY KEY (`id`)
    ) TYPE=MyISAM AUTO_INCREMENT=1;
                                
    CREATE TABLE `affiliates` (
        `id` tinyint(5) NOT NULL auto_increment,
        `name` varchar(32) NOT NULL,
        `image` varchar(100) NOT NULL,
        `url` varchar(100) NOT NULL,
        `description` mediumtext NOT NULL,
        `hits` tinyint(5) NOT NULL,
        PRIMARY KEY (`id`) 
    ) TYPE=MyISAM AUTO_INCREMENT=1;
    "
    ) or die ("Error Creating Tables! \n<br />\n" .mysql_error()); 
    When I run this code, I get this error:
    Error Creating Tables!
    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 '; CREATE TABLE `affiliates` ( `id` tinyint(5) NOT NULL au' at line 8
    Is there something I need to add to each line to make this work?

    Thanks
    Thanks DD, you saved me countless times

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Code:
    ) TYPE=MyISAM AUTO_INCREMENT=1;
    take out the auto_increment definition

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
  •