SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2002
    Location
    Barcelona, Spain
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL error creating databases (errno: 121)

    Anyone know what could be causing my MySQL error?

    "Can't create table '.\DBName\TableName.frm'(errno: 121)"

    It occurs sometimes when I run a php script to create a bunch of tables. When it occurs, I down and restart the MySQL server and the script runs OK.

    A sample from the script is below. The error relates to the CREATE TABLE query.

    PHP Code:
    $sql="DROP TABLE Application";

    if(@
    mysql_query($sql)){
        echo(
    "<p>Old Application table dropped.</p>");
    }else{
        echo(
    "<p>Error dropping old Application Table: " mysql_error() . " </p>");
    };

    $sql="CREATE TABLE Application(
        App_ID int auto_increment not null primary key,
        App_Name varchar(255) not null,
        App_Version varchar(255) not null,
        App_Language varchar(255) not null,
        App_Standard_Monthly_Fee decimal(10,2)not null,
        App_Current_Monthly_Fee decimal(10,2)not null
        ) type=innodb"
    ;

    if(@
    mysql_query($sql)){
        echo(
    "<p>New Application table created.</p>");
    }else{
        echo(
    "<p>Error creating Application Table: " mysql_error() . " </p>");
    }; 
    Last edited by Gary Bauer; Jun 21, 2002 at 03:07.

  2. #2
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Me too

    I suffer the same problem. I'm running 4.1.7-NT. Very similar code to Gary's (above) and it used to work just fine.

    I have found that if I separate the DROP table and Create Table commands into separate files, it's just fine. There seems to be an issue with giving DROP and CREATE statements in the same PHP file.

    HOWEVER, I have noticed today that this is also happeining in another file of mine. This one first detects the precence of a particular table by doing a SHOW TABLES and then uses rexeg to find the table I'm looking for. If it's there, we delete it and create another one. Or at least it used to.

    I *THINK* that the problem might be related to performing ANY query on the database BEFORE trying to CREATE a table. I've removed certain DB queries before the create statement and it just seems to do the same thing. I am going to try to re-write the code so that, before we run any general queries, we do a CREATE TABLE IF NOT EXISTS, so see if that works.


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
  •