INSERT Sometimes I did not insert all the data [closed]

0

I have a problem,

$alta = $_GET['alt-a'];
$altb = $_GET['alt-b'];
$altc = $_GET['alt-c'];
$altd = $_GET['alt-d'];

$correta = $_GET['correta'];
$img = $_SESSION['imagem'];
$questao = $_SESSION['questao'];


$inserta = mysqli_query($conn,"INSERT INTO alternativas VALUES ($codigo, '$alta', 'a'), ($codigo, '$altb', 'b'), ($codigo, '$altc', 'c'), ($codigo, '$altd', 'd') ");
$insert = mysqli_query($conn,"INSERT INTO questoes VALUES ($codigo, '$questao', '$img', '$correta')");
echo "Questão inserida com sucesso!";

When executing this script, in most cases it works normal ... but in some cases it does not insert all the information, in some cases it inserts the $ insert completely, and the $ insert that will be inserted 4 lines. . Sometimes I only insert two, the problem is always in the inserted $, sometimes I did not insert everything.

    
asked by anonymous 30.06.2016 / 22:30

2 answers

0

    
01.07.2016 / 15:20
1

I do not know very well what is giving error, but I can indicate a possible solution. Try to put the fields of the table that flying this is inserting in the query .... so type.

$insert = mysqli_query($conn,"INSERT INTO questoes(campo1,campo2,campo3,campo4) VALUES ($codigo, '$questao', '$img', '$correta')");
echo "Questão inserida com sucesso!";

I always put the names by default, and by organization in case someone picks up their code later, but in case you do not put can give some silly errors ... try putting in both insert, if not comment here. I hope I have collaborated!

    
30.06.2016 / 23:42