Is products_id
unique in the products_description
table?
If not, then that query against the products_description
table could return more than one row, and if that happens, MySQL will throw an error.
You can add a LIMIT 1
clause to the query as a workaround, to prevent more than one row from being returned.
(I don't have any other explanation as to why the trigger is "working" from phpMyAdmin when you perform an INSERT, but is "not working" when a script performs an INSERT... if the trigger was "working" before you added a couple of local variables, a second query and some additional assignments. I don't see anything wrong with the trigger, doesn't appear to be a problem with local variable name collisions with column names. Syntax looks correct.