MySQL CREATE TRIGGER using php -
this question has answer here:
i have read other posts mine, none of them solve problem, have 2 tables, user , purchase, when user signup, want add same user_id purchase table well. try right php code this:
$query = "create trigger `purchase_insert` after insert on `user` each row begin insert purchase (user_id) values (new.user_id)"; $result = mysqli_query($connection, $query); if($result){echo "<br>trigger success!";} else {die("<br>database query failed. " . mysqli_error($connection));}
this error get:
database query failed. have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 1
i'm sorry if question repetitious.
it should tick not single quotes
create trigger `purchase_insert` after insert on `user` each row begin insert purchase (user_id) values (new.user_id)
update
try this
delimiter$$ create trigger `purchase_insert` after insert on `user` each row begin insert purchase (user_id) values (new.user_id); end$$ delimiter ;
Comments
Post a Comment