mysql查询不起作用(同时运行两个INSERT)

bin*_*680 1 php mysql

我的代码中有一些查询

...
echo $query;
mysql_query($query) 
or die(mysql_error());
Run Code Online (Sandbox Code Playgroud)

当我运行它时,输出以下内容:

INSERT INTO test ( c1, c2, c3, c4, c5) 
VALUES ('xo', 'VxbcS','rzDMœSfsg', 'œsAcdiNwu','axaWMYOOj'); 
INSERT INTO test ( c1, c2, c3, c4, c5) 
VALUES ('ihTnUcBU', 'plKtJdsRT','PyJUPBx', 'f','SspBuWJiK'); 

You have an error in your SQL syntax; check the manual that corresponds 
to your MySQL   server version for the right syntax to use near 'INSERT 
INTO test ( c1, c2, c3, c4, c5) VALUES ('ihTnUcBU', 'plKtJdsRT',' at line 3
Run Code Online (Sandbox Code Playgroud)

如果我复制上面的插入查询并直接在phpmyadmin中运行它,它没有任何问题.但是当我运行php代码时它不起作用,是否有人知道这里看起来有什么问题?感谢帮助.

Nic*_*ssu 8

您可以一次只运行一个查询.

或使用多插入查询

INSERT INTO test ( c1, c2, c3, c4, c5) 
VALUES 
('xo', 'VxbcS','rzDMœSfsg', 'œsAcdiNwu','axaWMYOOj'), 
('ihTnUcBU', 'plKtJdsRT','PyJUPBx', 'f','SspBuWJiK'); 
Run Code Online (Sandbox Code Playgroud)