mysqli_stmt_bind_param 显示有关变量数量错误的错误,即使数量是正确的
mysqli_stmt_bind_param shows error about wrong number of variables even tho the number is correct
$insert_table = "INSERT INTO reviewst(name_show, score, content, author) VALUES('$name_show', '$score', '$review', '$author')";
$stmt = mysqli_prepare($conn, $insert_table);
if ($stmt === FALSE) {
echo "Error: " . mysqli_error($conn);
} else {
mysqli_stmt_bind_param($stmt, 'siss', $name_show, $score, $review, $author);
mysqli_stmt_execute($stmt);
}
错误:
Fatal error: Uncaught ArgumentCountError: The number of variables must match the number of parameters in the prepared statement in C:\xampp\htdocs\zp_milian_d_recenze\nav_links\create_review.php:77 Stack trace: #0 C:\xampp\htdocs\zp_milian_d_recenze\nav_links\create_review.php(77): mysqli_stmt_bind_param(Object(mysqli_stmt), 'siss', 'dfs', '1', 'fd', 'sdf') #1 {main} thrown in C:\xampp\htdocs\zp_milian_d_recenze\nav_links\create_review.php on line 77
我不知道为什么当 var 拼写正确、数据类型也正确且 var 数量也正确时它会显示此错误。
我试图在互联网上找到问题,但没有帮助,因为在 post 中总是存在语法问题、拼写错误的变量或错误的变量数量,我在这里正确地找到了这些问题。
使用?作为占位符,因此改变
$insert_table = "INSERT INTO reviewst(name_show, score, content, author) VALUES('$name_show', '$score', '$review', '$author')";
至
$insert_table = "INSERT INTO reviewst(name_show, score, content, author) VALUES(?,?,?,?)";
$insert_table = "INSERT INTO reviewst(name_show, score, content, author) VALUES('$name_show', '$score', '$review', '$author')";
$stmt = mysqli_prepare($conn, $insert_table);
if ($stmt === FALSE) {
echo "Error: " . mysqli_error($conn);
} else {
mysqli_stmt_bind_param($stmt, 'siss', $name_show, $score, $review, $author);
mysqli_stmt_execute($stmt);
}
错误:
Fatal error: Uncaught ArgumentCountError: The number of variables must match the number of parameters in the prepared statement in C:\xampp\htdocs\zp_milian_d_recenze\nav_links\create_review.php:77 Stack trace: #0 C:\xampp\htdocs\zp_milian_d_recenze\nav_links\create_review.php(77): mysqli_stmt_bind_param(Object(mysqli_stmt), 'siss', 'dfs', '1', 'fd', 'sdf') #1 {main} thrown in C:\xampp\htdocs\zp_milian_d_recenze\nav_links\create_review.php on line 77
我不知道为什么当 var 拼写正确、数据类型也正确且 var 数量也正确时它会显示此错误。
我试图在互联网上找到问题,但没有帮助,因为在 post 中总是存在语法问题、拼写错误的变量或错误的变量数量,我在这里正确地找到了这些问题。
使用?作为占位符,因此改变
$insert_table = "INSERT INTO reviewst(name_show, score, content, author) VALUES('$name_show', '$score', '$review', '$author')";
至
$insert_table = "INSERT INTO reviewst(name_show, score, content, author) VALUES(?,?,?,?)";