1
please could help me with the error below, I’m trying to Ravas this code data in a table but when I ask to record is returning the error:
Fatal error: Uncaught Error: Call to Undefined Function d/m/Y() in C: xampp htdocs Portalpib members.php:7 Stack trace: #0 {main} thrown in C: xampp htdocs Portalpib members.php on line 7
Follows code:
<?php
include("conexaobanco.php");
If(isset($_POST['nome'])){
$nome = filter_input(INPUT_POST, "nome", FILTER_SANITIZE_STRING);
$datanascimento = DateTime::createFromFormat('d/m/Y'(filter_input(INPUT_POST, "datanascimento", FILTER_SANITIZE_STRING)));
$datacasamento = DateTime::createFromFormat('d/m/Y'(filter_input(INPUT_POST, "datacasamento", FILTER_SANITIZE_STRING)));
$dataadmissao = DateTime::createFromFormat('d/m/Y'(filter_input(INPUT_POST, "dataadmissao", FILTER_SANITIZE_STRING)));
$datadesligamento = DateTime::createFromFormat('d/m/Y'(filter_input(INPUT_POST, "datadesligamento", FILTER_SANITIZE_STRING)));
$cargo = filter_input(INPUT_POST, "cargo", FILTER_SANITIZE_STRING);
$endereco = filter_input(INPUT_POST, "endereco", FILTER_SANITIZE_STRING);
$numero = filter_input(INPUT_POST, "numero", FILTER_SANITIZE_STRING);
$bairro = filter_input(INPUT_POST, "bairro", FILTER_SANITIZE_STRING);
$complemento = filter_input(INPUT_POST, "complemento", FILTER_SANITIZE_STRING);
$cidade = filter_input(INPUT_POST, "cidade", FILTER_SANITIZE_STRING);
$estado = filter_input(INPUT_POST, "estado", FILTER_SANITIZE_STRING);
$cep = filter_input(INPUT_POST, "cep", FILTER_SANITIZE_STRING);
$profissao = filter_input(INPUT_POST, "profissao", FILTER_SANITIZE_STRING);
$estadocivil = filter_input(INPUT_POST, "estadocivil", FILTER_SANITIZE_STRING);
$nomeconjuge = filter_input(INPUT_POST, "nomeconjuge", FILTER_SANITIZE_STRING);
$batizado = filter_input(INPUT_POST, "batizado", FILTER_SANITIZE_STRING);
$databatismo = DateTime::createFromFormat('d/m/Y'(filter_input(INPUT_POST, "databatismo", FILTER_SANITIZE_STRING)));
$igrejabatismo = filter_input(INPUT_POST, "igrejabatismo", FILTER_SANITIZE_STRING);
$email = filter_input(INPUT_POST, "email", FILTER_SANITIZE_STRING);
$telefone = filter_input(INPUT_POST, "telefone", FILTER_SANITIZE_STRING);
If(!$conn){
die("Falha na conexão com o banco de dados, procure o administrador do sistema e informe o erro abaixo: ". "<br>" .mysqli_connect_error());
}
If(empty($nome)||empty($email)){
echo "Preencha os campos corretamente!";
exit;
} else {
$sql = "INSERT INTO TB_MEMBROS (NOME, DATA_NASCIMENTO, DATA_CASAMENTO, DATA_ADMISSAO, DATA_DESLIGAMENTO, CARGO, ENDERECO, NUMERO, BAIRRO, COMPLEMENTO, CIDADE, ESTADO, CEP, PROFISSAO, ESTADO_CIVIL, NOME_CONJUGE, BATIZADO, DATA_BATISMO, IGREJA_BATISMO, EMAIL, TELEFONE) VALUES ('".$nome."', '".$datanascimento->format('Y-m-d')."', '".$datacasamento->format('Y-m-d')."', '".$dataadmissao->format('Y-m-d')."', '".$datadesligamento->format('Y-m-d')."', '".$cargo."', '".$endereco."', '".$numero."', '".$bairro."', '".$complemento."', '".$cidade."', '".$estado."', '".$cep."', '".$profissao."', '".$estadocivil."', '".$nomeconjuge."', '".$batizado."', '".$databatismo->format('Y-m-d')."', '".$igrejabatismo."', '".$email."', '".$telefone."')";
} If(mysqli_query($conn, $sql)){
echo "<script>Alert('Conta cadastrada com Sucesso!');</script>";
} else {
"Erro: " .$sql. "<br>" .mysqli_connect_error($conn);
}
}
?>
good, avoid so many parentheses
$datanascimento = DateTime::createFromFormat('d/m/Y', filter_input(INPUT_POST, 'datanascimento', FILTER_SANITIZE_STRING));
– user60252
William, really it was this comma, that gives to make the haste, however now it is returning me an error in the line of Insert - "Fatal error: Uncaught Error: Call to a Member Function format() on Boolean in C: xampp htdocs Portalpib membros.php:37 Stack trace: #0 {main} thrown in C: xampp htdocs Portalpib membros.php on line 37"
– Darezzo
It should probably be on some date, when doing
createFromFormat
of an error and returnsfalse
. Of severalvar_dump
and check the values that appears for each variable– Costamilam
Once William had settled, there was an unfilled field, when he passed blank he understood that he was a Boolean. I filled the field and passed... Thank you very much
– Darezzo