简体   繁体   中英

Can't figure out error 1064 in MySQL

#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 '$TABLE[] = "CREATE TABLE `perscom_admin_units` ( `primary_id_field` int(11) N' at line 1

Here is the query:

$TABLE[] = "CREATE TABLE `perscom_admin_units` (
  `primary_id_field` int(11) NOT NULL auto_increment,
  `name` text,
  `mos` mediumtext,
  `image` text,
  `responsibilities` mediumtext,
  `prerequisites` mediumtext,
  `forum_usergroup` text,
  PRIMARY KEY(primary_id_field)
);";

Any idea whats going wrong?

Just write this (remove $TABLE[]= ):

CREATE TABLE `perscom_admin_units` (
  `primary_id_field` int(11) NOT NULL auto_increment,
  `name` text,
  `mos` mediumtext,
  `image` text,
  `responsibilities` mediumtext,
  `prerequisites` mediumtext,
  `forum_usergroup` text,
  PRIMARY KEY(primary_id_field)
);

$TABLE is a PHP variable, I tink you just want to run MySQL code.

I think you are mysql lower version. Can you test these code.

          $TABLE[] = "CREATE TABLE perscom_admin_units (  primary_id_field int NOT 
     NULL   auto_increment,  name text,  mos mediumtext,  image text,  responsibilities mediumtext, prerequisites mediumtext,  forum_usergroup text, 
PRIMARY KEY(primary_id_field) )"; 

First test these SQL in mysql yog after you can put these SQL in your code

CREATE TABLE perscom_admin_units (  primary_id_field int NOT 
     NULL   auto_increment,  name text,  mos mediumtext,  image text,  responsibilities mediumtext, prerequisites mediumtext,  forum_usergroup text, 
PRIMARY KEY(primary_id_field) ); 

Thank you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM