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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    Registered User
    Join Date
    Jun 2002
    Location
    Arizona
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts

    creating mysql tables

    what is wrong with this?

    mysql_query("DROP TABLE IF EXISTS ". $pref[tablePre] ."posts;");
    mysql_query("CREAT TABLE posts (
    id int(10) NOT NULL auto_increment,
    date date NOT NULL default,
    name varchar(26) NOT NULL default,
    email varchar(100) NOT NULL default,
    homepage varchar(100) NOT NULL default,
    body text NOT NULL,
    PRIMARY KEY (id)
    )")

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    CREAT

    as opposed to CREATE I assume ?
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    New Coder
    Join Date
    Jul 2002
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this:
    PHP Code:
    mysql_query("DROP TABLE IF EXISTS "$pref[tablePre] ."posts;"); 
    mysql_query("CREATE TABLE posts ( 
    id int(10) NOT NULL auto_increment, 
    date date NOT NULL default, 
    name varchar(26) NOT NULL default, 
    email varchar(100) NOT NULL default, 
    homepage varchar(100) NOT NULL default, 
    body text NOT NULL, 
    PRIMARY KEY (id) 
    )"


  • #4
    Registered User
    Join Date
    Jun 2002
    Location
    Arizona
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i really need to stop trying to do this so late (early). thanks

  • #5
    Registered User
    Join Date
    Jun 2002
    Location
    Arizona
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You have an error in your SQL syntax near ' name varchar(26) NOT NULL default, email varchar(100) NOT NULL default,' at line 5

  • #6
    New Coder
    Join Date
    Jul 2002
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are typing this in phpMyAdmin?
    or using PHP file to create it?

  • #7
    Registered User
    Join Date
    Jun 2002
    Location
    Arizona
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    php file, i get the same thing in phpmyadmin when i take out and use the sql code.

  • #8
    New Coder
    Join Date
    Jul 2002
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this:

    PHP Code:
    <?php
    linkID 
    = @mysql_connect(localhost"username""password") or die(mysql_error());

    mysql_select_db("databasename"$linkID) or die(mysql_error());

    resultID mysql_query("CREATE TABLE posts(id int(10) NOT NULL auto_increment, date date NOT NULL default, name varchar(26) NOT NULL default, email varchar(100) NOT NULL default, homepage varchar(100) NOT NULL default, body text NOT NULL, PRIMARY KEY (id))"$linkID) or die(mysql_error());

    if (
    $resultID != FALSE)
    {
        print 
    "The query was successfully executed.";
    }
    else
    {
        print 
    "The Query was not successfully executed.";
    }

    mysql_close($linkID);

    ?>

  • #9
    Registered User
    Join Date
    Jun 2002
    Location
    Arizona
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    after i gave the two first variables " $ " it gives me an parse error on 11 which is where it tries to create the table.

    PHP Code:
    <?php

    $linkID 
    = @mysql_connect(localhost"""") or die(mysql_error());



    mysql_select_db("mysql"$linkID) or die(mysql_error());


    // error on below line
    $resultID mysql_query("CREATE TABLE posts(id int(10) NOT NULL auto_increment, date date NOT NULL default, name varchar(26) NOT NULL default, email varchar(100) NOT NULL default, homepage varchar(100) NOT NULL default, body text NOT NULL, PRIMARY KEY (id))"$linkID) or die(mysql_error());



    if (
    $resultID != FALSE)

    {

        print 
    "The query was successfully executed.";

    }

    else

    {

        print 
    "The Query was not successfully executed.";

    }



    mysql_close($linkID);



    ?>

  • #10
    New Coder
    Join Date
    Jul 2002
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php
    linkID 
    = @mysql_connect(localhost"username""password") or die(mysql_error());

    mysql_select_db("databasename"$linkID) or die(mysql_error());

    $resultID mysql_query("CREATE TABLE posts(id int(10) NOT NULL auto_increment, date date NOT NULL default, name varchar(26) NOT NULL default, email varchar(100) NOT NULL default, homepage varchar(100) NOT NULL default, body text NOT NULL, PRIMARY KEY (id))"$linkID) or die(mysql_error());

    if (
    $resultID != FALSE)
    {
        print 
    "The query was successfully executed.";
    }
    else
    {
        print 
    "The Query was not successfully executed.";
    }

    mysql_close($linkID);

    ?>

  • #11
    Registered User
    Join Date
    Jun 2002
    Location
    Arizona
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this works, i found the error

    PHP Code:
    <?php

    $linkID 
    = @mysql_connect(localhost"""") or die(mysql_error());

    mysql_select_db("chronicyouth"$linkID) or die(mysql_error());

    $resultID = ("CREATE TABLE posts(
        id int(10) NOT NULL auto_increment,
        date date NOT NULL default,
        name varchar(26) NOT NULL default,
        email varchar(100) NOT NULL default,
        homepage varchar(100) NOT NULL default,
        body text NOT NULL,
        PRIMARY KEY (id)
    ), $linkID"
    ) or die(mysql_error());

    if (
    $resultID != FALSE)
    {
        print 
    "The query was successfully executed.";
    }
    else
    {
        print 
    "The Query was not successfully executed.";
    }

    mysql_close($linkID);



    ?>
    ), $linkID") or die(mysql_error());

    was

    )", $linkID) or die(mysql_error());

    double quotes needed to be moved.

    now, one more problem. it says that it succeeds. but, i can't find it in the database.

  • #12
    New Coder
    Join Date
    Jul 2002
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh sorry.

  • #13
    New Coder
    Join Date
    Jul 2002
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Forgot to do a bunch of stuff, I'm sorry. Here's the code currected.

    PHP Code:
    <?php
    $linkID 
    = @mysql_connect("localhost""""") or die(mysql_error());

    mysql_select_db("database"$linkID) or die(mysql_error());

    $resultID mysql_query("CREATE TABLE posts(id int(10) NOT NULL auto_increment, date date NOT NULL default, name varchar(26) NOT NULL default, email varchar(100) NOT NULL default, homepage varchar(100) NOT NULL default, body text NOT NULL, PRIMARY KEY (id)), $linkID") or die(mysql_error());

    if (
    $resultID != FALSE)
    {
        print 
    "The query was successfully executed.";
    }
    else
    {
        print 
    "The Query was not successfully executed.";
    }

    mysql_close($linkID);

    ?>

  • #14
    Registered User
    Join Date
    Jun 2002
    Location
    Arizona
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You have an error in your SQL syntax near ' name varchar(26) NOT NULL default, email varchar(100) NOT NULL default, homepag' at line 1

    by the way thanks for your help

  • #15
    New Coder
    Join Date
    Jul 2002
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah I know.. this error is comfusing.. everthing seems currect.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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