Jump to content
eduardodsilvaq

Erro de cadastro - PDOStatement->execute()

Recommended Posts

Simplesmente nao entendo o erro...

 

Erro:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: parameter was not defined' in C:\AppServ\www\functions.php:102 Stack trace: #0 C:\AppServ\www\functions.php(102): PDOStatement->execute() #1 C:\AppServ\www\cadastro.php(34): cadastrarUsuario('eduardodsilvaq@...', '8888888888888', 'Eduardo Queiroz', 'Seller', '1990-10-10', '8888888888888') #2 {main} thrown in C:\AppServ\www\functions.php on line 102

 

Function:

function cadastrarUsuario ($x, $y, $q, $r, $w, $e){
	$token = md5(mt_rand(34, 38));
	$y = loginHash($y);
	$PDO =  Conexao::dbConnect();
	$sql = "INSERT INTO usuarios (email, senha, nome, usuario, data, telefone, token) VALUES (:email, :senha, :nome, usuario, :data, :telefone, :token)";
	$stmt = $PDO->prepare($sql);
	$stmt->bindParam(':email', $x);
	$stmt->bindParam(':senha', $y);
	$stmt->bindParam(':nome', $q);
	$stmt->bindParam(':usuario', $r);
	$stmt->bindParam(':data', $w);
	$stmt->bindParam(':telefone', $e);
	$stmt->execute();
	echo "<script>alert('Usuario cadastrado com sucesso.');window.location.href='login.php'</script>";
	exit;
}

 

Share this post


Link to post
Share on other sites
function cadastrarUsuario ($x, $y, $q, $r, $w, $e){
	$token = mt_rand(34, 38);
	$token = password_hash($token, PASSWORD_DEFAULT);
	$y = password_hash($y, PASSWORD_DEFAULT);
	$PDO =  Conexao::dbConnect();
	$sql = "INSERT INTO usuarios (email, senha, nome, usuario, data, telefone, token) VALUES (:email, :senha, :nome, usuario, :data, :telefone, :token)";
	$stmt = $PDO->prepare($sql);
	$stmt->bindParam(':email', $x);
	$stmt->bindParam(':senha', $y);
	$stmt->bindParam(':nome', $q);
	$stmt->bindParam(':usuario', $r);
	$stmt->bindParam(':data', $w);
	$stmt->bindParam(':telefone', $e);
	$stmt->bindParam(':token', $token);
	$stmt->execute();
	echo "<script>alert('Usuario cadastrado com sucesso.');window.location.href='login.php'</script>";
	exit;
}

O erro persiste:


Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in C:\AppServ\www\functions.php:99 Stack trace: #0 C:\AppServ\www\functions.php(99): PDOStatement->execute() #1 C:\AppServ\www\cadastro.php(34): cadastrarUsuario('eduardodsilvaq@...', '88888888888', 'Eduardo', 'SellerXD', '1995-05-20', '55 61 851624446') #2 {main} thrown in C:\AppServ\www\functions.php on line 99

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.