php and mysql not saved

Asked

Viewed 41 times

-3

I am making a simple registration in php and mysql only that it is not registering and playing in mysql I did a check in case of this error it returns repeated email , and this giving this message when I click save and not play in mysql


include_once("conexao.php");

$nome = $_POST['nome'];
$email = $_POST['email'];
$cargo = $_POST['cargo'];
$data = $_POST['data'];
$endereco = $_POST['endereco'];
$cidade = $_POST['cidade'];
$estado = $_POST['estado'];
$cpf = $_POST['cpf'];
$rg = $_POST['rg'];
$ctps = $_POST['ctps'];


$sql = "insert into usuarios (nome,email,cargo,data,endereco,cidade,estado,,cpf,rg,ctps)
 values ('$nome' , '$email' , '$cargo', '$data', '$endereco', '$cidade', '$estado','$cpf', '$rg', '$ctps')";

$salvar = mysqli_query($conexao,$sql); //comando para salvar query

$linhas = mysqli_affected_rows($conexao);

mysqli_close($conexao);

?>

  • Besides the one mentioned in the boy’s answer there, is your form with the "Names" right in the fields ? Ideally you just put the form HTML. The rest is dispensable for the question.

  • sorry buddy I’m getting on the stack here I’ll get the hang of it

  • Nothing, man. No need to apologize. It was just a comment I made. And I’m glad that the boy’s answer helped you. If you thought the answer was helpful, click on that "V" there in the answer to accept it and for the author of the answer to receive the score.

2 answers

1

It could be a (,) comma that’s getting in the way. Your example:

$sql = "insert into usuarios (nome,email,cargo,data,endereco,cidade,estado,,cpf,rg,ctps)

values ('$name' , '$email' , '$cargo', '$data', '$address', '$city', '$state', '$Cpf', '$rg', '$Ctps')";

Test like this:

`$sql = "insert into usuarios (nome,email,cargo,data,endereco,cidade,estado,cpf,rg,ctps)

values ('$name' , '$email' , '$cargo', '$data', '$address', '$city', '$state', '$Cpf', '$rg', '$Ctps')";`

-1

In the $sql command you have an extra comma after status!

$sql = "Insert into usuarios (name,email,position,date,address,city,state,,Cpf,rg,Ctps) ...

Take it out and see if it works!

  • top brother thanks was that Obrigad even I’m new here to start but I already want to become intermediary at least excuse noobisse

Browser other questions tagged

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