0
I just started in the area and came across this situation.
This my code is not inserting in my Mysql.
<?php
try{
$pdo = new PDO('mysql:host=localhost:3306;dbname=formularioecofin', 'SECRETO', 'SECRETO');
}
catch (PDOException $e )
{
echo 'Erro ao conectar com o MySQL: ' . $e->getMessage();
}
?>
$inserir_banco = $pdo->prepare("INSERT INTO 'formulariodadoscadastrais' (CNPJ, RazaoSocial, NomeFantasia, NomeResponsavel, Cpf, Telefone,CelularWhatsapp, Email) SET (?,?,?,?,?,?,?,?)");
$array_sql = array(
$novos_campos['nCNPJ'],
$novos_campos['nNome'],
$novos_campos['nFantasia'],
$novos_campos['nNomeResp'],
$novos_campos['nCPF'],
$novos_campos['nTelefone'],
$novos_campos['nCelular'],
$novos_campos['nEmail']
);
if($inserir_banco->execute($array_sql)){
$respostas['erro'] = 'nao';
$respostas['msg'] = 'Respostas cadastradas com sucesso!';
}else{
$respostas['erro'] = 'sim';
$respostas['getErro'] = 'Não foi possível cadastrar as respostas. Contate seu programador!';
}
};
Every time I give the Submit it returns "Could not register the answers. Contact your programmer!
Someone can give me a light?
Gives a var_dump($new_fields) and sees if the values are valid and fit with the data types set in the database. You can also connect the errors to see better what the problem is. For this you can use this code at the beginning of the script: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
– Antonio Alexandre