number of variables does not match the mysqli parameters

Asked

Viewed 27 times

1

Well I am trying to make a select "bindado" however this returning the following error Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn’t match number of Parameters in Prepared statement in

    $query = "SELECT * FROM duelos WHERE status='desafiado' AND desafiado='?'";
    $statement = $mysqli->prepare($query);

    //bind parameters for markers, where (s = string, i = integer, d = double,  b = blob)
    $statement->bind_param('s',$desafiante);
    $statement->execute();

    if($statement->execute()){
        print 'Voce foi desafiado por $desafiante <br> Aceitar o desafio? <br> Sim  -  Nao';
    }else{
        print 'Nada a relatar';
    }
    $statement->close();

1 answer

1


In your query there is no placeholder, values should not be passed directly but exchanged for only questions(?) it is not necessary to use simple quotes to escape them when using Prepared statements.

Change:

$query = "SELECT * FROM d
$statement->bind_param(si, $status ,$iddesafiante);uelos WHERE status='desafiado' AND iddesafiado='$iddesafiante'";

For:

$query = "SELECT * FROM duelos WHERE status = ? AND iddesafiado = ?";
$statement->bind_param('si', $status ,$iddesafiante);
  • continues the same error I will update the code the status I will pass manually

  • @Arsomnolasco challenged is a string or int?

  • is a string I changed the example

  • @Arsomnolasco Colca in single quotes types si I changed the answer

  • still continues , I updated the code to see how this

  • @Arsomnolasco will not quote in interrogations and call the execute() only once.

  • it was right here the error disappeared, but the return on print is not appearing any more that and other case . the question problem has been solved, if possible change the answer included these information

Show 2 more comments

Browser other questions tagged

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