Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/02/2008, 19:52
printonic
 
Fecha de Ingreso: diciembre-2007
Mensajes: 38
Antigüedad: 16 años, 4 meses
Puntos: 0
Error de sintaxis llaves foraneas al crear base de datos

me da este error:

Cita:
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 'FOREIGN KEY (Category) REFERENCES Categories (id) ON DELETE CASCADE ) ENGINE=In' at line 11
CREATE TABLE `Wallpapers` ( `ID` int(11) NOT NULL auto_increment, `Title` text NOT NULL, `Category` text NOT NULL, `Thumbnail` text NOT NULL, `Thumbdetails` text NOT NULL, `Image_Small` text NOT NULL, `Image_Large` text NOT NULL, `Hits` int(11) NOT NULL default '0', PRIMARY KEY (`ID`) FOREIGN KEY (Category) REFERENCES Categories (id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=82
Esta la tabla que inserto con los datos:

Código PHP:
$Base_SQL[] = "CREATE TABLE `Wallpapers` (
  `ID` int(11) NOT NULL auto_increment,
  `Title` text NOT NULL,
  `Category` text NOT NULL,
  `Thumbnail` text NOT NULL,
  `Thumbdetails` text NOT NULL,
  `Image_Small` text NOT NULL,
  `Image_Large` text NOT NULL,
  `Hits` int(11) NOT NULL default '0',
  PRIMARY KEY  (`ID`)
  FOREIGN KEY (Category) REFERENCES Categories (id) ON DELETE CASCADE 
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=82 ;
"

Que puede ser? si le quito esta linea me deja insertarlo bien.

FOREIGN KEY (Category) REFERENCES Categories (id) ON DELETE CASCADE

Última edición por printonic; 20/02/2008 a las 21:27