1
Good afternoon, I am trying to enter data in a database and I have as return the error message: "It was not possible to register the user".
I’m using Xamp software, with Apache and Mysql installed.
The code is as follows:
<head>
<meta charset="UTF-8">
<meta http-equiv="content-type">
<title>Adicao Usuario Banco de Dados</title>
</head>
<body>
<?php
echo "<h1>ADICAO DE USUARIO</h1>";
$conexao_bd = mysql_connect("localhost");
if(!$conexao_bd) {
echo "<p><b>Não foi possível conectar ao Banco de Dados</b></p>";
echo mysql_error();
}
else {
mysql_select_db("db_hotel",$conexao_bd);
$retorno = mysql_query("INSERT INTO usuarios(Nome_Usuario,Senha_Acesso) VALUES('ADMIN','M45T3R')");
if(!$retorno)
echo "<h2>Nao foi possivel cadastrar o usuario!</h2>";
else
echo "<h2>Usuario cadastrado com sucesso!</h2>";
}
mysql_close($conexao_bd);
?>
</body>
If you can help me, from now on....
Show what’s inside '$return'. Give a var_dump($return). Maybe it’s a connection error with your bd.
– Vinícius
Hi @Walter. Catch the bug with the code
echo(mysqli_error($conexao_bd));
in theif(!$retorno)
and put in your question.– João Martins
Change
echo "<h2>Nao foi possivel cadastrar o usuario!</h2>";
forecho mysql_error();
– rray
Which version of PHP you are using?
– bfavaretto