$query = "INSERT INTO abc VALUES ('1', '2', '3')";
$send_to_mysql = mysqli_query($connection, $query);
行。
$query = "CREATE TABLE abc (a varchar(255), b varchar(255), c varchar(255))";
$send_to_mysql = mysqli_query($connection, $query);
行。
$query = "CREATE TABLE abc (a varchar(255), b varchar(255), c varchar(255))";
$query .= "INSERT INTO abc VALUES ('1', '2', '3')";
$send_to_mysql = mysqli_multi_query($connection, $query);
NOP。问题出在哪里?
答案 0 :(得分:2)
在两个查询之间加一个分号。当您将两个查询放在一个单独的字符串中时,需要将它们分开,以便MySQL了解您确实有两个查询:
$query = "CREATE TABLE abc (a varchar(255), b varchar(255), c varchar(255));";
$query .= "INSERT INTO abc VALUES ('1', '2', '3')";
答案 1 :(得分:0)
将分号作为两个查询之间的分隔符,例如
$query = "CREATE TABLE abc (a varchar(255), b varchar(255), c varchar(255));";
mysqli_multi_query($connection, $query);
$query = "INSERT INTO abc VALUES ('1', '2', '3')";
$send_to_mysql = mysqli_multi_query($connection, $query);