'mysqli_stmt_bind_param shows error about wrong number of variables even tho the number is correct [duplicate]

$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);
}

ERROR:

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

I have no clue, why it shows this error when vars are spelled correctly, data types are also correct and number of vars is correct as well.

I tried to find the problem on internet, but it wasn't helpful, because in the post there was always problem with syntax, misspelled variables or wrong number of vars which I have correctly here.



Solution 1:[1]

Use ? as placeholders, Hence change

$insert_table = "INSERT INTO reviewst(name_show, score, content, author) VALUES('$name_show', '$score', '$review', '$author')";

to

$insert_table = "INSERT INTO reviewst(name_show, score, content, author) VALUES(?,?,?,?)";

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ken Lee