Results 1 to 4 of 4

Thread: [RESOLVED] Create table not working!

Threaded View

  1. #1

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Resolved [RESOLVED] Create table not working!

    Hi,

    I'm using code I have used before to create a database! While I can create the database for some reason it won't allow me to create the table. This is the code I am using to create the database:

    PHP Code:
    <?php
    //connect to server or exit
    require_once("php/conroot.php");

    //create database
    $query "CREATE DATABASE IF NOT EXISTS $dbDatabase";
    if (
    mysql_query($query$conn)) {
    echo (
    "Database create query successful");
    }
    //select database
    if (mysql_select_db($dbDatabase$conn)) {
    echo (
    "Database selection successful");
    }else {
    die (
    "Could not locate $dbDatabase database" .mysql_error());
    }

    //create table
    $query "CREATE TABLE IF NOT EXISTS $table  (
    'id' int(2) NOT NULL auto_increment unique,
      'Nameochild' varchar(30) default NULL,
      'Address' varchar(30) default NULL,
      'Email' varchar(50) default NULL,
      'Mobile' varchar(20) default NULL,
      'Postcode' varchar(6) default NULL,
      DOB' varchar(20) default NULL,
      'Phone' varchar(10) default NULL,
      'Medical' varchar(100) default NULL,
      'Photo' varchar(1) default NULL,
      'Guardian' varchar(20) default NULL,
       'Date'(8) default NULL,
      PRIMARY KEY  ('id')
    ) TYPE=MyISAM"
    ;


    if (
    mysql_query($query$conn)) {
    echo (
    "table $table query successful");
    }
    ?>
    Edit:

    Here is the code for conroot.php:

    PHP Code:
    <?php
    //connect to db
    $conn mysql_connect("localhost""root""");
    if (!
    $conn) {
    die(
    "Connection failed: " .mysql_error());
    }
    // Database connection variables
    $dbDatabase "database";
    $table "table";
    ?>
    Have I missed anything? I have looked over the code and cant see anything that might be wrong.


    Thanks,


    Nightwalker
    Last edited by Nightwalker83; Feb 20th, 2010 at 01:31 AM. Reason: Adding more
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

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