Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    multiple tables in one php

    i have a real wierd prob :'(
    i have one file working.php which creates a database, selects it and then creates a table.another file drop.php drop that particular database.
    first when i executed the working.php file, the database and table were created.then i dropped the database using drop.php.
    then i made a few changes in working.php to create two more table. but now the same file wont give any output.
    i am viewing the files in internet explorer.it gives absolutly no output. ???running drop.php gives the error
    Error dropping database: Can't drop database 'mydatabase'; database doesn't exist
    it makes sense since working.php is not working but wht should i do


    working.php

    PHP Code:
    <?php
    $con 
    mysql_connect("127.0.0.1","root","12345");
    if (!
    $con)
      {
      echo 
    "Could not connect: ' . mysql_error();
      }


    if (mysql_query("
    CREATE DATABASE mydatabase",$con))
      {
      echo 'Database created  ';
      }
    else
      {
      echo "
    Error creating database" . mysql_error();
      }


    if(!mysql_select_db("
    mydatabase"))
    {
    die('Could not select database: mydatabase ' . mysql_error());
    }

     echo "
    Database selected     ";

    if (mysql_query("
    CREATE TABLE customer
                                 
    (f_name VARCHAR(15NOT NULL,
                                  
    l_name VARCHAR(15NOT NULL,
                                  
    phone  VARCHAR(11) ,
                                  
    account INT UNSIGNED PRIMARY KEY)")
       )
    {
      echo 'table created';
      }
    else
      {
      echo "  
    Error creating table customer" . mysql_error();
      }
    if (mysql_query("
    CREATE TABLE account
                                  
    (account2 INT(7UNSIGNED PRIMARY KEY,
                      
    password VARCHAR(4NOT NULL,
                                  
    balance  FLOAT(3) ,
                                  
    valid_till DATE YYYY-MM-DD)")
       )
    {
    echo "
    created account table";
    }
    else
    {
     echo "
    account nt created   " .mysql_error();
    }

    if (mysql_query("
    CREATE TABLE Transaction
                                  
    (id INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
                      
    source INT(7UNSIGNED,
                                  
    destination  INT(7UNSIGNED,
                                  
    amount INT(3NOT NULL,
                                  
    date DATE YYYY-MM-DD,
                      
    strt_time TIME 00:00:00,
                                  
    end_time  TIME 00:00:00 ,
                                  
    status ENUM("TRUE","FALSE"NOT NULL)")
       )
    {
    echo("
    created transaction table";
    }
    else
    {
     echo "
    tran nt created   " .mysql_error();
    }

    ?>


    drop.php

    <?php
    $con = mysql_connect("
    127.0.0.1","root","12345");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }

    echo '1  ';

    if (mysql_query("
    DROP DATABASE mydatabase",$con))
      {
      echo 'Database dropped  ';
     }
    else
      {
     echo "
    Error dropping database" . mysql_error();
     }
    mysql_close($con);
    ?>
    any idea what to do?im completely new and now lost
    Last edited by guelphdad; 02-27-2007 at 11:43 PM.


 

Posting Permissions

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