help already tried everything to solve my problem with mysqli

Asked

Viewed 36 times

-4

Hello everyone I’m with a problem I can not understand or solve I’m novice in php. this code it inserts the data into the normal database but of that error.

Warning: mysqli_stmt::bind_param(): 
  Number of variables doesn't match number of parameters in prepared statement in

Insertion code

$insert_data =("INSERT INTO acompanhamento (nome, email, fone, mensagem, date, hora, local, tipoproc, inlineRadioOptions, num_processo) 
VALUES ('".$dados['nome']."', '".$dados['email']."', '".$dados['fone']."','".$dados['mensagem']."','".$dados['date']."','".$dados['hora']."','".$dados['local']."','".$dados['tipoproc']."','".$dados['inlineRadioOptions']."','".$dados['num_processo']."')");

$insert_data = $conn->prepare($insert_data);
$insert_data->execute();
$insert_data->bind_param('ssssssssss', $nome,$email,$fone,$mensagem,$date,$hora,$local,$inlineRadioOptions,$num_processo,$tipoproc);

2 answers

0

Friend advise to share a little more of your code, but basically the error is that you are passing eleven arguments in INSERT and your bindPrepare has ten.

Try to do something similar to this example: $sql = "INSERT INTO employees (name, address, salary) VALUES (:name, :address, :salary)";

$Pdo->prepare($sql); // Bind variables to the Prepared statement as Parameters $stmt->bindParam(":name", $param_name); $stmt->bindParam(":address", $param_address); $stmt->bindParam(":salary", $param_salary); $stmt->execute();

0


Here is a valid example:

// prepare and bind
$stmt = $conn->prepare("INSERT INTO MyGuests (firstname, lastname, email) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $firstname, $lastname, $email);

In VALUES you just needed to put the ? placeholders to bind later.

https://www.w3schools.com/php/php_mysql_prepared_statements.asp

  • Our many thanks I got thank you very much, only replace the value by ??? and it worked perfectly.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.