Error in adding PHP + MySqli data

1

please help me with the error below, I'm trying to write this code data to a table but when I ask to write it 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

Follow the code below:

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

?>
    
asked by anonymous 09.10.2018 / 20:43

2 answers

2

All date rows are 'd/m/Y'( correct would be 'd/m/Y', (

The error was really attention, without passing the comma, it would be like trying to invoke the function d/m/Y , which I believe is not what you want

    
09.10.2018 / 21:36
0

Man, by mistake he is not recognizing his date, I'll leave an example php date syntax here.

  <?php
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
// Mountain Standard Time (MST) Time Zone

$today = date("F j, Y, g:i a");                 // March 10, 2001, 5:16 pm
$today = date("m.d.y");                         // 03.10.01
$today = date("j, n, Y");                       // 10, 3, 2001
$today = date("Ymd");                           // 20010310
$today = date('h-i-s, j-m-y, it is w Day');     // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.');   // it is the 10th day.
$today = date("D M j G:i:s T Y");               // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \i\s\ \m\o\n\t\h');     // 17:03:18 m is month
$today = date("H:i:s");                         // 17:16:18
$today = date("Y-m-d H:i:s");                   // 2001-03-10 17:16:18 (the MySQL DATETIME format)
?>

and the link: link

    
09.10.2018 / 21:02