-1
I am making a form to insert data in my database but the function that does this is returning me a syntax error that I cannot find.
Function
function insereProduto($conexao, $nome, $descricao, $tamanho, $quantidade)
{
$query = "insert into uniformes (nome, descricao, tamanho , quantidade)
values ('.$nome.', '.$descricao.', '.$tamanho.', .$quantidade.);";
return mysqli_query($conexao, $query);
}
Error:
O produto Camisa Polo não foi adicionado: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.)' at line 2
Swap these points for keys. It looks like you made a very wrong concatenation in your SQL command.
– Woss
I put these points because it was going wrong when I used the keys
– Luhan Salimena
Bizarre that now was :|
– Luhan Salimena
Bizzarro is to wrap a variables with simple quotes and point and $quantity only with hahaha points. I’m not saying it would work but there was no uniformity in the syntax. Wrapping them all in single quotes works too.
– user60252
I tried to put the points because a guy helped me here in the login system and the code had been ' . '
$query = "select * from usuarios where email='".$email."'";
– Luhan Salimena
But note that between the single quotes there are still the double quotes, to get out of the string and concatenate. You did not put these double quotes.
– Woss