Các mysqli_query [] của MySQLI_Query [] mong đợi ít nhất 2 tham số, 1 lỗi đã gặp phải khi gặp phải phương thức mysqli_Query [] không nhận được các tham số phù hợp.“mysqli_query[] expects at least 2 parameters, 1 given” error is encountered when the mysqli_query[] method does not receive proper parameters.
Lỗi này xảy ra khi chúng ta chỉ truyền một tham số cho hàm mysqli_query [], vì hàm mysqli_query có hai tham số - một kết nối cơ sở dữ liệu và thứ hai là chuỗi truy vấn.mysqli_query[] function, as the mysqli_query function takes two parameter - one database connection and the second is a query string.
Hãy để chúng tôi đi vào các chi tiết.
Error Code Code
Mã lỗi
mysqli_query["SELECT * FROM table_employee"];
Mã chính xác
mysqli_query[$conn, "SELECT * FROM table_employee"];
Trong ví dụ trên, bạn có thể thấy rằng chúng ta chỉ chuyển một tham số cho hàm truy vấn mysqli_query [], trong dòng mysqli_query ["Chọn * từ Table_employee"].mysqli_query["SELECT * FROM table_employee"].
Lỗi được nêu ra ở đây khi hàm mysqli_Query [] chỉ lấy một tham số là chuỗi truy vấn. Như chúng ta biết rằng hàm mysqli_query [] là an toàn, nó yêu cầu kết nối cơ sở dữ liệu và chuỗi truy vấn để kích hoạt truy vấn vào cơ sở dữ liệu.mysqli_query[] function takes only one parameter that is query string. As we know that the mysqli_query[] function is secure, it requires a database connection and a query string to fire the query to the database.
Ví dụ về Corect:
Ở đây, có thể quan sát thấy rằng phương thức mysqli_Query [] có 2 tham số. Vì vậy, lỗi được tránh và mã chạy tốt. & nbsp; mysqli_query[] method takes 2 parameters. So, the error is avoided and the code runs fine.
mysqli_query
jcwebb tại dicoe dot com ¶
15 năm trước -- mysqli_query — Performs a query on the database
Table myCity successfully created.
Select returned 10 rows.
Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...
6
Thông tin tại FF Dot Net
Igor ¶ mysqli::query[string $query
, int $result_mode
= MYSQLI_STORE_RESULT
]:
mysqli_result|bool
13 năm trước[mysqli $mysql
, string $query
, int $result_mode
= MYSQLI_STORE_RESULT
]:
mysqli_result|bool
Ahmed dot 3abdolah tại gmail dot com ¶mysqli_real_query[] followed by either mysqli_use_result[] or mysqli_store_result[].
8 năm trước:
hunreal tại gmail dot commysqli_query[] that is longer than
2 of the server, the returned error codes are different depending on whether you are using MySQL Native Driver [mysqli_query["SELECT * FROM table_employee"];
3] or MySQL Client Library [mysqli_query["SELECT * FROM table_employee"];
4]. The behavior is as follows:mysqli_query["SELECT * FROM table_employee"];
18 năm trước
Thomas Dekker ¶
Popere Dot Noel tại Yahoo Dot Com ¶
9 năm trước
Omidbahrami1990 tại Gmail Dot Com ¶Blinki Bill, Argodak tại Yahoo Dot Com ¶mysqli object returned by mysqli_connect[] or mysqli_init[]
5 năm trướcDavid Marcus ¶
Hàm mysqli_query [] làm gì?Hàm mySQLI_Query [] chấp nhận giá trị chuỗi đại diện cho một truy vấn là một trong các tham số và, thực thi/thực hiện truy vấn đã cho trên cơ sở dữ liệu.
MySQLI_Query [] cần bao nhiêu tham số để kết nối và truy vấn thành công với cơ sở dữ liệu? [default] - returns a mysqli_result object with buffered result set.
Phần lớn sự tương tác của bạn với MySQL trong PHP sẽ được thực hiện bằng hàm mysqli_query [], có ít nhất hai tham số: kết nối cơ sở dữ liệu bạn muốn truy vấn và truy vấn SQL bạn muốn thực hiện. - returns a mysqli_result object with unbuffered result set. As long as there are pending records waiting to be fetched, the connection line will be busy and all subsequent calls will return error
mysqli_query[$conn, "SELECT * FROM table_employee"];
4. To avoid the error all records must be fetched from the server or the result set must be discarded by calling mysqli_free_result[]. Mysqli_query return giá trị nào? [available with mysqlnd] - the query is performed asynchronously and no result set is immediately returned.
mysqli_poll[] is then used to get results from such queries. Used in combination with either MYSQLI_STORE_RESULT
or
3 constant. mysqli_query[$conn, "SELECT * FROM table_employee"];
Trả về các giá trị ¶ Đối với các truy vấn thành công tạo ra một tập kết quả, chẳng hạn như chọn, hiển thị, mô tả hoặc giải thích, mysqli_query [] sẽ trả về đối tượng mysqli_result. Đối với các truy vấn thành công khác, mysqli_query [] sẽ trả về đúng.
Các tham số mysqli_connect là gì?
8 on failure. For successful queries which produce a result set, such as mysqli_query[$conn, "SELECT * FROM table_employee"];
mysqli_query[$conn, "SELECT * FROM table_employee"];
9 or
0,
mysqli_query[] will return a mysqli_result object. For other successful queries, mysqli_query[] will return
1. Giá trị tham số.
[Php 5, Php 7, Php 8]mysqli::query[] example
Thông tin tại FF Dot Net
2
3
4Phong cách thủ tục
2
3
7Các ví dụ trên sẽ xuất ra một cái gì đó tương tự như:
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...
Xem thêm
- mysqli_real_query [] - thực hiện truy vấn SQL
- mysqli_multi_query [] - thực hiện một hoặc nhiều truy vấn trên cơ sở dữ liệu
- mysqli_prepare [] - Chuẩn bị một câu lệnh SQL để thực thi
- mysqli_free_result [] - giải phóng bộ nhớ liên quan đến kết quả
Nuntius ¶ ¶
14 năm trước
8
9Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...0
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...1
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...2
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...3
họ tại Gmail dot com ¶
11 năm trước
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...4
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...5
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...6
Petrus.jvr ¶ ¶
11 năm trước
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...7
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...8
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...6
Petrus.jvr ¶ ¶
Ẩn danh ¶
$query
0
$query
1
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...6
4 năm trước ¶
Người nổi ¶
$query
3
$query
4
$query
5
$query
6
$query
7
$query
816 năm trước ¶
Đăng ký tại jdfoxmicro dot com
$query
9
$result_mode
0
$result_mode
1
$result_mode
2
$result_mode
3
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...6
12 năm trước ¶
XA tại sagexa dot com ¶
$result_mode
5
20 ngày trước ¶
14 năm trước
$result_mode
6
$result_mode
7
$result_mode
8
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...6
họ tại Gmail dot com ¶
11 năm trước
MYSQLI_STORE_RESULT
0
MYSQLI_STORE_RESULT
1
Ẩn danh ¶ ¶
Người nổi ¶
MYSQLI_STORE_RESULT
3
MYSQLI_STORE_RESULT
4
MYSQLI_STORE_RESULT
5
MYSQLI_STORE_RESULT
6
MYSQLI_STORE_RESULT
716 năm trước ¶
Đăng ký tại jdfoxmicro dot com
MYSQLI_STORE_RESULT
8
MYSQLI_STORE_RESULT
9
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...6
12 năm trước ¶
XA tại sagexa dot com ¶
$mysql
1
$mysql
2
$mysql
320 ngày trước ¶
CEO tại L-i-e Dot Com ¶
$mysql
4
$mysql
5
$mysql
6
$mysql
7
$mysql
8
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...6
jcwebb tại dicoe dot com ¶ ¶
Đăng ký tại jdfoxmicro dot com
$query
0
$query
1
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...6
12 năm trước ¶
XA tại sagexa dot com ¶
$query
3
$query
4
$query
5
$query
6
Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...6
20 ngày trước ¶
Ẩn danh ¶
$query
8
$query
9
mysqli_query["SELECT * FROM table_employee"];
004 năm trước ¶
XA tại sagexa dot com ¶
mysqli_query["SELECT * FROM table_employee"];
01mysqli_query["SELECT * FROM table_employee"];
02mysqli_query["SELECT * FROM table_employee"];
03mysqli_query["SELECT * FROM table_employee"];
04mysqli_query["SELECT * FROM table_employee"];
05mysqli_query["SELECT * FROM table_employee"];
06Table myCity successfully created. Select returned 10 rows. Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now in...6
Petrus.jvr ¶ ¶
Ẩn danh ¶
mysqli_query["SELECT * FROM table_employee"];
084 năm trước ¶
Ẩn danh ¶
mysqli_query["SELECT * FROM table_employee"];
09