Entering register in data group - error

Asked

Viewed 39 times

0

Good afternoon, I have an error when registering some data in my database. Follow a part of the code and the error that appears.

include_once("settings.php");
        $con = mysqli_connect(HOST, USER, PASS);
        $query = "SELECT bd_winfo FROM cadastro WHERE login = '".$login."'";
        $cadastrar = "INSERT INTO cadastro (nome, sobrenome, data, cpf, email, pais, estado, login, senha, rsenha)
                      VALUES ('$nome', '$sobrenome', '$data', '$cpf', '$email', '$pais', '$estado', '$login', '$senha', '$rsenha')";
                if(mysqli_query($cadastrar, $con))
                {
                    $_SESSION['nome'] = $nome;
                    $_SESSION['sobrenome'] = $sobrenome;
                    $_SESSION['data'] = $data;
                    $_SESSION['cpf'] = $cpf;
                    $_SESSION['email'] = $email;
                    $_SESSION['pais'] = $pais;
                    $_SESSION['estado'] = $estado;
                    $_SESSION['login'] = $login;
                    $_SESSION['senha'] = $senha;    
                    $_SESSION['rsenha'] = $rsenha;                  


                    header('Location: cadastroRealizado.php');




                }

EDIT: The error part is in the line: if(mysqli_query($register, $con)) inserir a descrição da imagem aqui

  • It worked, but now is not making the registration in the database, error.

2 answers

0


You forgot to pass the connection before the query.

$con = mysql_connect("localhost","marcelo","9090","banco_de_dados");
$query = "SELECT * from users";
mysqli_query($con, $query);

0

You reversed the parameters of mysqli_query.

The right thing would be mysqli_query($con,$cadastrar)

Browser other questions tagged

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