1
I’m breaking the hook with this code for some time now, it’s the first time I’m using the PDO class of PHP and I’m having an error that I don’t know how to solve.
<?php
include "conexao.php";
$banco = new Banco(); //Instanciando o banco de dados
$filtro = array("/", "-", ".", "(", ")", " "); //Filtro de caracteres indesejados
$nome = $_GET['nome'];
$senha = $_GET['senha'];
$email = $_GET['email'];
$nascimento = str_replace($filtro, "", $_GET['nascimento']);
$telefone = str_replace($filtro, "", $_GET['telefone']);
$resultado = $banco->prepare("INSERT INTO clientes(id_cliente, nome_cliente,
email_cliente, telefone_cliente, senha_cliente,
data_nasc_cliente) VALUES(NULL, :nome, :email,
:telefone, :senha, :nascimento");
$resultado->execute(array(
':nome' => $nome,
':email' => $email,
':telefone' => $telefone,
':senha' => $senha,
':nascimento' => $nascimento
));
The code above is not entering in the table.
Which error is displayed?
print_r($resultado->errorInfo());
.id_cliente
is a field with auto increment? sure usingNULL
will work?– stderr
@stderr Auto increment is correct, the
print_r
generated an error that I cannot identify in the codeArray ( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 4 )
– Estêvão Silva
@stderr no, keeps giving the same error
– Estêvão Silva
@stderr removed them, the error remains the same
– Estêvão Silva
I gave up using PDO in the project, I’m using mysqli now
– Estêvão Silva