Pass variable in UPDATE PDO PHPERRO: Pdostatement::execute(): SQLSTATE[HY093]

Asked

Viewed 138 times

0

@$c_matricula = $_POST['numero'];
@$data_aa = $_POST['data_aa'];
@$data_ff = $_POST['data_ff'];

if(isset($data_aa)){

    @$dataa = date("Y-m-d H:i:s");

    $pdo = $dbconn->prepare("UPDATE contato SET c_data_andamento = :data_a WHERE c_matricula = :c_matricula");
    // $stmt->bindParam(':data_a', $data_a);
    // $stmt->bindParam(':c_matricula', $c_matricula);
    $pdo->execute();

// header("Location: listar_contato.php");
}

else

{

    $pdo = $dbconn->prepare("UPDATE contato SET c_data_finalizado=:data_f WHERE c_matricula = :numero");
    $pdo->execute();

I’m getting a post another page, if that post exist need to execute a query past the current date, otherwise I pass another query.

Erro:Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in C:\xampp\htdocs\programacao\avanco_contato.php on line 34
  • and what’s the problem?

  • php bursts an error stating that the parameter is invalid

  • who is $data_a? What’s line 34? Why the bindParam are commented? In $stmt->bindParam(':data_a', $data_a) is expected $data_a that is missing from your code.

1 answer

0


@$c_id = "2";
@$c_data_andamento = date("Y-m-d H:i:s");

 $pdo = $dbconn->prepare("UPDATE contato SET c_data_andamento = :c_data_andamento WHERE c_id = :c_id");
    $pdo->bindParam(':c_data_andamento', $c_data_andamento);
    $pdo->bindParam(':c_id', $c_id);
    $pdo->execute();

Browser other questions tagged

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