I'm trying to set up a reference between two tables, and I keep running into this error when I load the page.
Error creating table: Cannot add foreign key constraint
This is the 'calendars' table: calendars table image
And this is the current query I am running to create the table:
CREATE TABLE `'.$classTableName.'`(
classID INT(11) NOT NULL,
name VARCHAR(255) NOT NULL,
users INT(11) NOT NULL,
files INT(11) NOT NULL,
chats INT(11) NOT NULL,
deadlines INT(11) NOT NULL,
calendar INT(11) NOT NULL,
PRIMARY KEY (classID),
FOREIGN KEY (calendar) REFERENCES calendars(classID)
) ENGINE=INNODB;
Any help would be appreciated! :)