How to register more information in the table

Asked

Viewed 47 times

-8

This is my code:

$nome = $_POST['nome'];
$rg = $_POST['rg'];
$endereço = $_POST['endereço'];
$conta = $_POST['conta'];
$agencia = $_POST['agencia'];
$operação = $_POST['operação'];
$bandeira = $_POST['bandeira'] ;
//insere dados na tabela
$sql = "INSERT INTO diaristas (nome, rg, edereço, conta, agencia, operação, bandeira, DataCadastro) VALUES ($nome, $rg, $endereço, $conta, $agencia, $operação, $bandeira,)";
//confere se cadastrado ou não.
if (mysqli_query($strcon, $sql)) {
      echo "Profissional Cadastrado com Sucesso.";
} else {
      echo "Error: " . $sql . "<br>" . mysqli_error($strcon);
}
mysqli_close($strcon);

He returns to me :

Error: INSERT INTO diarists (name, rg, edereço, account, agency, operation, flag, VALUES (Natan Martins, 1, 1, 1, 001 - Account Corrente de Pessoa Física, BRADESCO,) 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 ' o, account, agency, operation, flag, ) VALUES (Natan Martins, 1, 1, 1,' at line 1

I can’t fix it, can you help me please?

  • 1

    Isn’t the setting for the special characters? it seems to me that he is complaining of the ç in address... tries to delcarar them using a crase before and after the column name

  • I looked at the characters, I was using ç. I switched everything from variables to parameters including the database to simplify. helped a lot. Thank you!

2 answers

1

A parameter in VALUES is missing. You put in a comma, but you didn’t put in the parameter

0


Note that the error you sent right after VALUES is missing a quotation mark

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 ' o, account, agency, operation, flag, ) VALUES (', Natan Martins','171' at line 1

Try to do so by putting "'.$variable.'" (double quotes, single and stitch to add)

Also change the c and the ã, because of the problem in the bank. S

$sql = "INSERT INTO diaristas (nome, rg, endereco, conta, agencia, operacao, bandeira, DataCadastro) VALUES ("'.$nome.'", "'.$rg.'", "'.$endereco.'", "'.$conta.'", "'$agencia."', "'.$operação.'", "'.$bandeira.'")";

Browser other questions tagged

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