MYSQL doesn't want to create a table with the name of a gap.



  • When a table is created (the name of which goes along with the heading and the content through the form) there is a mistake if in the title of the table two words through the gap.

    Makes a mistake:

    "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 'gdfg (id INT (11)NOT NULL AUTO_INCREMENT,title VARCHAR(100) NULL DEULFAT 0 ,cont' at line 1"

    where "gdfg" is the second word in the title of the table, there is no problem in the title, but if there are two words in the title, there's a mistake.

    The design code looks like:

    $comand="CREATE TABLE $category_ (id INT (11)NOT NULL AUTO_INCREMENT,title VARCHAR(100) NULL DEFAULT 0 ,content VARCHAR(4096) NULL DEFAULT 0,
        data TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,PRIMARY KEY (id))";
        mysql_query($comand)or die(mysql_error());
        $comand="INSERT INTO $category_ (title, content) VALUES ('$titles','$contents')";
        mysql_query($comand)or die(mysql_error());
    


  • Since gaps are used to separate SQL parts, they are may not be part of the name of the table (or any other object such as the index). Stressing ( _ ) - usually used to separate words in the names of the tables.

    You can name a table with a gap, but only in astrophes. It also depends on Mysql.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2