如何通过mysqli_multi_query()插入多行? [英] How to insert multiple rows by mysqli_multi_query()?
本文介绍了如何通过mysqli_multi_query()插入多行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用mysqli_multi_query()
进行多次插入,以下是我的代码.问题是它没有执行结果.请让我知道我做错了什么?
I am trying to do multiple insertions using mysqli_multi_query()
and following is my code. The issue is its not executing the result . Kindly let me know what i did wrong?
$query = "INSERT INTO crap_table (name, number, class)VALUES ('Peter', 35,'BS')";
$query .= "INSERT INTO crap_table (name, number, class)VALUES ('Sahil', 35,'MS')";
mysqli_multi_query($con,$query);
推荐答案
mysqli_multi_query
执行一个或多个由分号连接的查询.
Executes one or multiple queries which are concatenated by a semicolon.
您之间必须有一个;
.喜欢
You need to have a ;
between them. Like
$query = "INSERT INTO crap_table (name, number, class)VALUES ('Peter', 35,'BS');";
^
$query .= "INSERT INTO crap_table (name, number, class)VALUES ('Sahil', 35,'MS')";
提供您已经连接到数据库了吗?喜欢
Provided that you are connected to the database already? Like
$con= mysqli_connect("localhost", "my_user", "my_password", "world");
这篇关于如何通过mysqli_multi_query()插入多行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文