+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: can't create tables anymore

  1. #1
    dani22 is offline x10Hosting Member dani22 is an unknown quantity at this point
    Join Date
    Oct 2009
    Posts
    15

    can't create tables anymore

    I tried to create a table like I use to do but it's not working anymore. I don't get any fail messages but the table is not created. Has it something to do with the recently made Mysql updates? I don't understand...

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: can't create tables anymore

    Quote Originally Posted by dani22 View Post
    I tried to create a table like I use to do
    And how was that? cPanel? Using phpMyAdmin's table wizard? Running a query from phpMyAdmin? Running a query from a script? Something else? When asking for help, be precise and informative.
    Last edited by misson; 02-11-2010 at 08:37 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    dani22 is offline x10Hosting Member dani22 is an unknown quantity at this point
    Join Date
    Oct 2009
    Posts
    15

    Re: can't create tables anymore

    Quote Originally Posted by misson View Post
    And how was that? cPanel? Using phpMyAdmin's table wizard? Running a query from phpMyAdmin? Running a query from a script? Something else? When asking for help, be precise and informative.
    "Running a query from a script?" jepp, that's how, like I've done thousand times before.

    Code:

    // Connects to your Database
    $con = mysql_connect("localhost", "xxxxxx", "xxxxxxx");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("md7dani2_haveroom", $con);

    mysql_query("CREATE TABLE subscr(ID varchar(30),check varchar(5))");
    mysql_query("INSERT INTO subscr(ID,check) VALUES ('Daniel','Yes')");

    mysql_close($con);

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: can't create tables anymore

    Have you tried doing it via PHPmyAdmin?

    I ask this just to see where the problem might lie. I know you want to be able to do it via script.
    Nothing is always absolutely so.

  5. #5
    dani22 is offline x10Hosting Member dani22 is an unknown quantity at this point
    Join Date
    Oct 2009
    Posts
    15

    Re: can't create tables anymore

    haven't done that. How do I write the query in phpMyadmin? I've Tried different querys: CREATE TABLE subscr(ID varchar(30),check varchar(5)); ,but no success.

    "#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 'varchar(5))' at line 1"

    thx in advance.

  6. #6
    garikr's Avatar
    garikr is offline x10Hosting Member garikr is an unknown quantity at this point
    Join Date
    Aug 2009
    Posts
    46

    Re: can't create tables anymore

    The problem is that you named one of your columns 'check' apparently 'check' is some kind of command or constant in MySql. So this should work:
    CREATE TABLE subscr(ID varchar(30),checkid varchar(5));, or whatever you'll name it.
    I've done this before spent hours in computercidal rage, trying to figure out what's wrong, only to find out that one of my variables is the reserved word.
    Hope this will help.
    P.S. I would set up mysql on your home computer/laptop, it's much easier to check queries that way, before plugging 'em into your script.
    Last edited by garikr; 02-12-2010 at 05:49 PM.

  7. #7
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: can't create tables anymore

    Nice catch. Didn't even pay attention to the column names.

    But, I just used phpMyAdmin to create a table, using their 'wizard' which generated this code:

    Code:
    CREATE TABLE `XXXXX_test`.`test01` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
    `check` INT NOT NULL ,
    PRIMARY KEY ( `id` ) 
    ) ENGINE = MYISAM ;
    and the table was created.

    Maybe you have to make sure to quote the field name.
    Nothing is always absolutely so.

  8. #8
    rkalhans's Avatar
    rkalhans is offline x10Hosting Member rkalhans is an unknown quantity at this point
    Join Date
    Dec 2009
    Posts
    33

    Re: can't create tables anymore

    event with the same column name you might be to create a table
    try this

    mysql_query("CREATE TABLE subscr(`ID` varchar(30),`check` varchar(5))");
    mysql_query("INSERT INTO subscr(`ID`,`check`) VALUES ('Daniel','Yes')");
    notice the col-name enclosed in a back-tick (`)
    One should alwaz use this to prevent any such problem.
    The same thing can also be used in table names if there is such a problem esp when we need to create tables based on user input

    P.S.@ DESCALZO Quote may not work in such situations.
    Last edited by rkalhans; 02-12-2010 at 02:23 PM.

  9. #9
    garikr's Avatar
    garikr is offline x10Hosting Member garikr is an unknown quantity at this point
    Join Date
    Aug 2009
    Posts
    46

    Re: can't create tables anymore

    You are right, descalzo, using ` around the check does the trick. I didn't even know you can use ` in mysql. ` and not '. I think that's the first time I've used that key on my keyboard. Any other languages accept ` in their syntax??
    P.S. so "back-tick" is it's name...
    Last edited by garikr; 02-12-2010 at 02:25 PM.

  10. #10
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: can't create tables anymore

    Some languages use `command` to execute shell commands (if it is enabled).

    I cannot think of any (besides SQL) that use `backticks` like 'single' or "double" quotes.
    Nothing is always absolutely so.

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 6
    Last Post: 12-17-2010, 08:35 PM
  2. SQL Azure with ASP Dot Net
    By zegnhabi in forum Tutorials
    Replies: 0
    Last Post: 12-13-2009, 04:32 PM
  3. How can I create tables for my mySQL Database?
    By nyakerz in forum Tutorials
    Replies: 10
    Last Post: 06-06-2009, 05:03 PM
  4. Create your own free forum using x10Hosting
    By Gigacore in forum Tutorials
    Replies: 46
    Last Post: 12-01-2008, 03:07 PM
  5. create table in mysql@x10hosting
    By giganticgaint in forum Free Hosting
    Replies: 1
    Last Post: 09-05-2008, 10:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers