Create MySQL CHILD and PARENT records at the same time and set CHILD.PARENT_ID by using MySQL Triggers
I think you have to perform this trigger before insert child row and there is a lot of errors in your code.


You must declare variables in the beginning of the script.
You give values to variables with SET
Only LAST_INSERT_ID() function is necessary and if you perform the trigger before update, you only have to set NEW value, and that's it.




DELIMITER $$
DROP TRIGGER `database_name `.`trigger_name` $$
CREATE
    TRIGGER `database_name `.`trigger_name` BEFORE INSERT
    ON `database_name `.`child_table`
    FOR EACH ROW BEGIN
    DECLARE last_id int;
    INSERT INTO  `database_name`.`parent_table`(id) VALUES (0);

    SET NEW.parent_id = LAST_INSERT_ID();
END $$
DELIMITER;