Unexpected Error in PDO class

Asked

Viewed 21 times

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 using NULL will work?

  • @stderr Auto increment is correct, the print_r generated an error that I cannot identify in the code Array ( [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 )

  • @stderr no, keeps giving the same error

  • @stderr removed them, the error remains the same

  • I gave up using PDO in the project, I’m using mysqli now

1 answer

2


Missing close a parentheses at the end of the connection string

...VALUES(NULL, :nome, :email, :telefone, :senha, :nascimento)");

FML

Browser other questions tagged

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