Trying to make an update to two tables at once using PHP but the tables have foreign keys linking them. Normally I would set an @variable with LAST_INSERT_ID() but this won't work within the PHP code.
$newclass = "INSERT INTO PT_Classes(`Title`, `Details`, `Location`, `Time`, `Date`)
VALUES ('$title', '$details', '$location','$ntime', '$ndate');
SET @last_id_PT_Classes = LAST_INSERT_ID();
INSERT INTO PT_Calendar(`Date`, `Class`, `Details`)
VALUES ('$ndate', @last_id_PT_Classes,'$title');
";however keep getting a "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SET @last_id_PT_Classes = LAST_INSERT_ID(); INSERT INTO PT_Calendar(`Dat' at line 3"
Anyone know a way around this?
Aucun commentaire:
Enregistrer un commentaire