SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2008
    Location
    Amsterdam, NL, and France
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    My CREATE TABLE doesn't work!

    Hi,

    The code below runs, does nothing and the system gives the message following the code. Can anybody tell me what I'm missing?

    Thanks,

    Mike

    $query = "
    CREATE TABLE keywordstab
    (
    keyword VARCHAR(25) NOT NULL,
    booknr INT (6) NOT NULL,
    PRIMARY KEY(keyword)
    )";

    "#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$query = " CREATE TABLE keywordstab ( keyword VARCHAR(25) NOT NUL' at line 1"
    * * * * My site * * * *
    * * * * My paintings * * * *

  2. #2
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try it directly in the mysql client, works fine for me. You may have introduced an error on php end.

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2008
    Location
    Amsterdam, NL, and France
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Thanks for your reply but I don't understand what you mean by
    Quote Originally Posted by guelphdad View Post
    Try it directly in the mysql client, ....
    .
    Could you give me more info.
    You mentioned a php error, here's the complete program.

    Mike
    <?php
    include("misc.inc");

    $connection = mysql_connect($host,$user,$password)
    or die ("No connection");
    $db = mysql_select_db($database,$connection)
    or die ("No selection");
    $query = "
    CREATE TABLE keywordstab
    (
    keyword VARCHAR(25) NOT NULL,
    booknr INT (6) NOT NULL,
    PRIMARY KEY(keyword)
    )";
    ?>
    * * * * My site * * * *
    * * * * My paintings * * * *

  4. #4
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,033
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    You didn't execute the query

    Code php:
    <?php
    include("misc.inc");
     
    $connection = mysql_connect($host,$user,$password)
    or die ("No connection");
    $db = mysql_select_db($database,$connection)
    or die ("No selection");
    $query = "
    CREATE TABLE keywordstab
    (
    keyword VARCHAR(25) NOT NULL,
    booknr INT (6) NOT NULL,
    PRIMARY KEY(keyword)
    )";
    mysql_query($query, $db);
    ?>

    (note the mysql_query($query, $db); at the end).
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2008
    Location
    Amsterdam, NL, and France
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ScallioXTX,

    I changed the mysql_query statement slightly to

    $result = mysql_query($query, $connection);

    And it worked

    Thanks for your quick help.

    Mike
    * * * * My site * * * *
    * * * * My paintings * * * *


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
  •