Results 1 to 4 of 4

Thread: MySQL: CREATE TABLE

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    MySQL: CREATE TABLE

    I'm having a problem with this:

    PHP Code:
        $db mysql_connect("localhost""user""password");
        
    mysql_select_db("database",$db);
        
    $sql "INSERT INTO cats (name,tablename) VALUES ('$name','$tablename')";
        
    $sql2 "CREATE TABLE $tablename (id tinyint(4) DEFAULT '0' NOT NULL AUTO_INCREMENT,  name varchar(20),  desc text,  code text,  PRIMARY KEY (id),  UNIQUE id (id))";

        
    $result mysql_query($sql);
        
    $result2 mysql_query($sql2); 
    What's wrong with this code?

    The INSERT INTO works, but the CREATE TABLE never creates the table??
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    desc is a reserved word, for the ORDER BY SQL statement. That may be causing your problem.

    I would make your result2 the following to see what MySQL Error you get:

    PHP Code:
    result2 mysql_query2($sql2) or die(mysql_error()); 
    -Matt
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  3. #3

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by cpradio
    desc is a reserved word, for the ORDER BY SQL statement. That may be causing your problem.

    I would make your result2 the following to see what MySQL Error you get:

    PHP Code:
    result2 mysql_query2($sql2) or die(mysql_error()); 
    -Matt
    and that it was. Thanks alot, Matt.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    yep i had that same problem the other day
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width