SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Php create table concatenating problem

    Hi Everyone

    I'm trying to do this:
    <?
    mysql_query("CREATE TABLE $table_name (
    id INT NOT NULL AUTO_INCREMENT,
    PRIMARY KEY(id),
    name VARCHAR(30),
    age INT)")
    or die(mysql_error());

    ?>

    but I keep getting this error:

    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 '( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), age INT' at line 1

    I think it's a concatenating problem but I don't know how to fix it. Any help will be greatly appreciated.


    Regards

    Anwar

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this:

    CREATE TABLE $table_name (
    id INT NOT NULL AUTO_INCREMENT,
    PRIMARY KEY(id),
    name VARCHAR(30),
    age INT);

  3. #3
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?
    mysql_query("CREATE TABLE $table_name (
    id INT NOT NULL AUTO_INCREMENT,
    PRIMARY KEY(id),
    name VARCHAR(30),
    age INT)")
    or die(mysql_error());

    ?>
    $table_name does not contain any value. make sure it does.


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
  •