您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 12 行的“CREATE TABLE IF NOT EXISTS administracia(userID INT(255) NOT NULL AUTO_INCREME”附近使用正确的语法
这是查询或多或少也更具可读性的版本
$data = "
CREATE TABLE IF NOT EXISTS zamestnanci(
userID INT(255) NOT NULL AUTO_INCREMENT,
osobnecislo VARCHAR(50) NOT NULL,
meno VARCHAR(50) NOT NULL,
priezvisko VARCHAR(50) NOT NULL,
nick VARCHAR(50) NOT NULL,
heslo CHAR(128) NOT NULL,
previerka VARCHAR(15) NOT NULL,
PRIMARY KEY (userID,nick))
ENGINE=INNODB DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS administracia(
userID INT(255) NOT NULL AUTO_INCREMENT,
osobnecislo VARCHAR(50) NOT NULL,
meno VARCHAR(50) NOT NULL,
priezvisko VARCHAR(50) NOT NULL,
nick VARCHAR(50) NOT NULL,
heslo CHAR(128) NOT NULL,
previerka VARCHAR(15) NOT NULL,
PRIMARY KEY (userID,nick))
ENGINE=INNODB DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS navrhy(
navrhID INT(255) NOT NULL AUTO_INCREMENT,
nazov VARCHAR(50) NOT NULL,
text VARCHAR(505) NOT NULL,
schvalenie VARCHAR(15) NOT NULL,
datum VARCHAR(50) NOT NULL,
pridal VARCHAR(50) NOT NULL,
hlasovali VARCHAR(8000) NOT NULL,
kategoria VARCHAR(50) NOT NULL,
stroj VARCHAR(50) NOT NULL,
ano VARCHAR(1000) NOT NULL,
nie VARCHAR(1000) NOT NULL default '0',
PRIMARY KEY (navrhID))
ENGINE=INNODB DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS problemovyartikel(
artikelID INT(255) NOT NULL AUTO_INCREMENT,
artikelcisloVARCHAR(50) NOT NULL,
text VARCHAR(255) NOT NULL,
datum VARCHAR(50) NOT NULL,
pridal tinytext NOT NULL,
problem_cislo VARCHAR(100) NOT NULL,
PRIMARY KEY (artikelID))
ENGINE=INNODB DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS kategorie(
kategoriaID INT(255) NOT NULL AUTO_INCREMENT,
Nkategoria VARCHAR(50) NOT NULL,
Pkategoria VARCHAR(50) NOT NULL,
PRIMARY KEY (kategoriaID))
ENGINE=INNODB DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS novinky(
novinkaID INT(255) NOT NULL AUTO_INCREMENT,
novinka mediumtext NOT NULL,
PRIMARY KEY (novinkaID))
ENGINE=INNODB DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS stroje(
strojID INT(255) NOT NULL AUTO_INCREMENT,
stroj text NOT NULL,
PRIMARY KEY (strojID))
ENGINE=INNODB DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS kontakt(
kontaktID INT(255) NOT NULL AUTO_INCREMENT,
pole1 text NOT NULL,
pole2 text NOT NULL,
PRIMARY KEY (kontaktID))
ENGINE=INNODB DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS problem_cislo(
problem_cisloID INT(255) NOT NULL AUTO_INCREMENT,
problem_cislo VARCHAR(100) NOT NULL,
PRIMARY KEY (problem_cisloID))
ENGINE=INNODB DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS stranky(
strankaid INT(255) NOT NULL AUTO_INCREMENT,
stranka mediumtext NOT NULL,
stranka_obsah longtext NOT NULL,
subor mediumtext NOT NULL,
PRIMARY KEY (strankaid))
ENGINE=INNODB DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS chyby(
strankaid INT(255) NOT NULL AUTO_INCREMENT,
stranka CHAR(128) NOT NULL,
stranka_obsah VARCHAR(15) NOT NULL,
PRIMARY KEY (strankaid))
ENGINE=INNODB DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
INSERT INTO administracia (userID,osobnecislo,meno,priezvisko,nick,heslo,previerka) VALUES('1','admin','admin','admin','admin','59db9e61d015935901442385d992dd34346dbe3439174fee700b56f27ad445ee42e052c0c014892a70cea63b912c7a3ee55c7c42e9e36e0f169ab7e6b886fd21','admin');
INSERT INTO kategorie (kategoriaID,Nkategoria) VALUES('1','kategoria1');
INSERT INTO novinky (novinkaID,novinka) VALUES('1','novinka1<br>novinka2');
INSERT INTO stroje (strojID,stroj) VALUES('1','stroj1');
INSERT INTO kontakt (kontaktID,pole1,pole2) VALUES('1','testificate','0912 345 678');
INSERT INTO problem_cislo (problem_cisloID,problem_cislo) VALUES('1','problem1');
INSERT INTO chyby (strankaid,stranka_obsah,stranka) VALUES('1','Registrácia prebehla úspešne!','úspech'),('2','Návrh bol úspešne pridaný!','úspech'),('3','Problémový artikel bol úspešne pridaný!','úspech'),('4','Aktivácia prebehne čo najskôr alebo ste zadali nesprávne údaje!,'totok')";
编辑:
使用以下函数拆分和执行查询:
$queries = preg_split("/;+(?=([^'|^\\\']*['|\\\'][^'|^\\\']*['|\\\'])*[^'|^\\\']*[^'|^\\\']$)/",$data);
foreach ($queries as $query)
if(strlen(trim($query)) > 0)
mysql_query($query); {
$spracovat = mysql_query($data,$prepojenie) or die(mysql_error());