I'm creating a very simple database administrator with PHP but for some reason I can not get the foreign keys to work with "on delete cascade". To add a foreign key column I am first creating the new column and then making it a foreign key:
alter table '.$_SESSION["table"]." add ".$_SESSION["table"]
alter table ' .$_SESSION["table"]." add foreign key (".$_SESSION["field"].") references ".$_SESSION["referencedtable"]."(".$_SESSION["referencedfield"].") on delete cascade
I am showing the resulting SQL query on the screen, it looks correct, there are no PHP or SQL errors, but when I create a new element with information in the corresponding foreign key column with some element of the related table and delete the "master" element ", the" child "element is not cascaded.
I have verified that "foreign_key_checks" is at 1.