一个 mysql_query() 查询中的 PHP 多个 MYSQL 命令

2022-01-23 00:00:00 command php mysql

我想用一个 mysql_query 函数发出多个 mysql 命令.这是我的代码:

I want to issue multiple mysql commands with one mysql_query function. This is my code:

$query .= "INSERT INTO `users` VALUES(1,'stack','overflow');";
$query .= "INSERT INTO `posts` VALUES('other','stack','overflow');";
mysql_query($query);

如果我这样做,我会收到一条警告,指出我的语法不正确.如果我回显输出,复制它并在 phpMyAdmin 中执行它就可以了.

If I do that I get a warning that my syntax would be incorrect. If I echo the output, copy it and execute it in phpMyAdmin it works.

哪里出错了?

推荐答案

我觉得你需要这个??http://us2.php.net/manual/en/mysqli.multi-query.php

相关文章