Problema al crear tablas en mysql desde PHP

Buenas a todos antes de nada decir que llevo un largo tiempo de inactividad y puede que se me pasen algunas cosillas aun.

También dar las gracias a todo aquel que me pueda hechar una mano.

Resulta que estoy creando una página web la cual tiene un instalador automático.

El instalador funciona perfectamente hasta que llegamos al momento de crear las tablas en la base de datos.

Las tablas las intento crear con una consulta usando la extensión mysqli en estilo procedural.

El error que me devuelve MySQL es error de sintaxis pero ejecutando la consulta desde phpmyadmin o desde MySQL workbench(administrador gráfico) funcionan las consultas perfectamente asique como no encuentro la solución me he decidido a postear aquí por si veis algo que ami se me pase.

el código SQL que inserto es el siguiente.

$SqLconfiguracion = "
		create table if not exists wkConfig(
		  tipoConf varchar(50) primary key,
		  contenido text(500) not null,
		  descripcion text(1000) not null,
		  estado char(3) not null
		)ENGINE=MyISAM DEFAULT CHARSET=utf8;

		create table if not exists wkPlugins(
			id smallint(5) unsigned primary key,
			nombre varchar(255) not null unique,
			ruta varchar(255) not null,
			descripcion text(2000),
			activo char(3) not null
		)ENGINE=MyISAM DEFAULT CHARSET=utf8;
	
		create table if not exists wkPages(
		    id smallint(5) unsigned auto_increment primary key,
		    titulo varchar(255) not null unique,
		    recurso smallint(5) unsigned not null,
		    contenido text(2000) not null,
		    url varchar(255) not null unique,
		    slug varchar(255) not null unique,
			FOREIGN KEY (recurso) REFERENCES wkRecurso(id) ON DELETE CASCADE
		)ENGINE=MyISAM DEFAULT CHARSET=utf8;

		create table if not exists wkRecurso(
		    id smallint(5) unsigned auto_increment primary key,
		    nombre varchar(255) not null unique,
			tipo varchar(255) not null,
		    ruta text(2000) not null,
		    tamaño varchar(255) not null,
		    extension char(4) not null
		)ENGINE=MyISAM DEFAULT CHARSET=utf8;

		create table if not exists wkMenu(
			id smallint(5) unsigned auto_increment primary key,
			nombrePestana varchar(30) not null,
			destino varchar(255) not null unique
		)ENGINE=MyISAM DEFAULT CHARSET=utf8;

		create table if not exists wkSubMenu(
			id smallint(5) unsigned auto_increment primary key,
			idMenu smallint(5) unsigned not null,
			nombrePestana varchar(30) not null,
			destino varchar(255) not null unique,
			FOREIGN KEY (idMenu) REFERENCES wkMenu(id) ON DELETE CASCADE
		)ENGINE=MyISAM DEFAULT CHARSET=utf8;

		create table if not exists wkLogs(
			id int(11) unsigned auto_increment primary key,
			accionRealizada varchar(255) not null,
			fallo varchar(255) not null,
			fechaError date not null,
			sitioDeError varchar(255) not null,
			usuario varchar(255),
			direcIP varchar(30) not null
		)ENGINE=MyISAM DEFAULT CHARSET=utf8;

		create table if not exists wkBugs(
			id smallint(5) unsigned auto_increment primary key,
			descripcion text(1000) not null,
			ubicacionBug text(500) not null
		)ENGINE=MyISAM DEFAULT CHARSET=utf8;

		create table if not exists wkSugerencias(
			id smallint(5) unsigned auto_increment primary key,
			tituloSuge varchar(255) not null,
			contenido text(500) not null,
			fecha date not null,
			autor varchar(255),
			tipoSuge varchar(255) not null
		)ENGINE=MyISAM DEFAULT CHARSET=utf8;
	";

El error me lo da al crear la tabla wkPlugins
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 'create table if not exists wkPages( id smallint(5) unsigned auto_increment' at line 8

He probado también a crear tablas de forma individual y si funciona, mi pregunta es hay alguna forma de poder introducir la sentencia SQL entera sin tener que dividirla en trozos.


Gracias por el tiempo que le podais dedicar.
Hola!

Dices que te funcionan en PHPMyAdmin y MySQL Workbench? Me parece raro que funcionen... Pensando de manera estricta, no puedes crear una tabla que contenga una FOREIGN KEY hacia una tabla que aún no existe.

La tabla que produce el error, wkPages, tiene una referencia FK hacia la tabla wkRecurso, la que aún no se ha creado. Teóricamente, lo siguiente debería funcionar:

$SqLconfiguracion = " 
        create table if not exists wkConfig( 
          tipoConf varchar(50) primary key, 
          contenido text(500) not null, 
          descripcion text(1000) not null, 
          estado char(3) not null 
        )ENGINE=MyISAM DEFAULT CHARSET=utf8; 

        create table if not exists wkPlugins( 
            id smallint(5) unsigned primary key, 
            nombre varchar(255) not null unique, 
            ruta varchar(255) not null, 
            descripcion text(2000), 
            activo char(3) not null 
        )ENGINE=MyISAM DEFAULT CHARSET=utf8;

        create table if not exists wkRecurso( 
            id smallint(5) unsigned auto_increment primary key, 
            nombre varchar(255) not null unique, 
            tipo varchar(255) not null, 
            ruta text(2000) not null, 
            tamaño varchar(255) not null, 
            extension char(4) not null 
        )ENGINE=MyISAM DEFAULT CHARSET=utf8; 
     
        create table if not exists wkPages( 
            id smallint(5) unsigned auto_increment primary key, 
            titulo varchar(255) not null unique, 
            recurso smallint(5) unsigned not null, 
            contenido text(2000) not null, 
            url varchar(255) not null unique, 
            slug varchar(255) not null unique, 
            FOREIGN KEY (recurso) REFERENCES wkRecurso(id) ON DELETE CASCADE 
        )ENGINE=MyISAM DEFAULT CHARSET=utf8;

        create table if not exists wkMenu( 
            id smallint(5) unsigned auto_increment primary key, 
            nombrePestana varchar(30) not null, 
            destino varchar(255) not null unique 
        )ENGINE=MyISAM DEFAULT CHARSET=utf8; 

        create table if not exists wkSubMenu( 
            id smallint(5) unsigned auto_increment primary key, 
            idMenu smallint(5) unsigned not null, 
            nombrePestana varchar(30) not null, 
            destino varchar(255) not null unique, 
            FOREIGN KEY (idMenu) REFERENCES wkMenu(id) ON DELETE CASCADE 
        )ENGINE=MyISAM DEFAULT CHARSET=utf8; 

        create table if not exists wkLogs( 
            id int(11) unsigned auto_increment primary key, 
            accionRealizada varchar(255) not null, 
            fallo varchar(255) not null, 
            fechaError date not null, 
            sitioDeError varchar(255) not null, 
            usuario varchar(255), 
            direcIP varchar(30) not null 
        )ENGINE=MyISAM DEFAULT CHARSET=utf8; 

        create table if not exists wkBugs( 
            id smallint(5) unsigned auto_increment primary key, 
            descripcion text(1000) not null, 
            ubicacionBug text(500) not null 
        )ENGINE=MyISAM DEFAULT CHARSET=utf8; 

        create table if not exists wkSugerencias( 
            id smallint(5) unsigned auto_increment primary key, 
            tituloSuge varchar(255) not null, 
            contenido text(500) not null, 
            fecha date not null, 
            autor varchar(255), 
            tipoSuge varchar(255) not null 
        )ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    ";
Muchas gracias por responder.

El problema persiste, si las genero de forma individual las crea pero si intento crear varias tablas en la misma consulta(conexión) no me deja y me sale error de sintaxis.

Si me pudieseis hecharme una mano a averiguar el porque os lo agradecería ya que me estoy volviendo un pelin loco.
Acabo de solucionar el problema el problema era una Ñ que tenia puesta en la tabla wkRecurso en el campo tamaño, de todas formas muchas gracias por la ayuda.
Jajajaja, que bueno que lo hayas resuelto :), la verdad no me fijé en los caracteres :P.

En todo caso, lo primero que dije, siempre debes seguirlo porque a veces los gestores de base de datos (oracle, principalmente) no admiten que las tablas referenciadas se creen después de crear la referencia (foreign key).