COMMIT后无法执行任何MySQL查询

I execute some MySQL queries using START TRANSACTION, but after I execute COMMIT the following queries do not take effect in the database

The following queries were executed using mysqli_query in the same order:

SET names utf8

SET AUTOCOMMIT=0

START TRANSACTION

INSERT INTO table1 (a, b) VALUES (1,2) ;

INSERT INTO table2 (c, d) VALUES (1,1) ;

INSERT INTO table2 (c, d) VALUES (2,1) ;

COMMIT

INSERT INTO table3 (e, f) VALUES (9,7) ; <-- This does not insert anything!!

Note: The last query should be executed out of the START TRANSACTION COMMITblock.

That is really driving me crazy. Because I cannot seem to figure out the problem!!

The problem is because of the SET AUTOCOMMIT=0, so I'll have to query COMMIT after each query.

So the solution is either to set the SET AUTOCOMMIT=1 or to use COMMIT after each query.

I think the problem is the order of the instructions. Try to execute commit at the end.

SET names utf8

SET AUTOCOMMIT=0

START TRANSACTION

INSERT INTO table1 (a, b) VALUES (1,2) ;

INSERT INTO table2 (c, d) VALUES (1,1) ;

INSERT INTO table2 (c, d) VALUES (2,1) ;

INSERT INTO table3 (e, f) VALUES (9,7) ;

COMMIT