SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)

    Weird MySQL problem...

    I am using a variable to create a table in the database that I have.... The code is as follows,

    PHP Code:
    $createUsers "CREATE TABLE users (id INTEGER AUTO_INCREMENT PRIMARY KEY,username VARCHAR(200),password VARCHAR(200));";

    mysql_query($createUsers); 
    This does not work!!! I printed the query out and everything looks fine. I put the query directly into phpMyAdmin and it works fine. I execute the query like this:

    PHP Code:
    mysql_query("CREATE TABLE users (id INTEGER AUTO_INCREMENT PRIMARY KEY,username VARCHAR(200),password VARCHAR(200));"); 
    And that works fine! Can I not put the query into a variable and then execute it?? Or is there some other explanation?

    Thanks,

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried

    PHP Code:
    mysql_query($createUsers) or DIE(mysql_error()); 
    To see what exactly is failing?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Take out the semicolon at the end of the SQL query.
    ck :: bringing chris to the masses.


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
  •