Returning the NULL value

1

Someone can help me, I am making a code to insert data into a table in the database and update too, but unfortunately it is not working, all variables are giving NULL and the code itself that selects the table too gives NULL when I make the var_dum ().

However where is the error? I have checked several times, the connection to the database is okay because it shows other tables k also has connection only when I do the POST to insert k does not accept. It only shows the value of the variable when I make a purpose error in the selection of the table. Anyone have an idea?

<?php if(isset($_POST['button'])) {

$code_aluno=$_POST['code_aluno'];
$disciplina=$_POST['disciplina'];
$id_trabalho= $_POST['id_trabalho'];
$nota = $_POST['nota'];
$id = $_GET['id'];


$sql_trb_bimestra = "SELECT * FROM trabalhos WHERE id ='$id_trabalho'";

$resulta_trb_bimestre = mysqli_query($conexao, $sql_trb_bimestra);

while ($res_trb_bimestre = mysqli_fetch_assoc($resulta_trb_bimestre)) {

$bimestre = $res_trb_bimestre['bimestre'];

$sql_post = "UPDATE envio_trabalho SET status = 'Accepted', nota = '$nota' WHERE id = '$id_trabalho' AND discipline ='$disciplina'";
mysqli_query($conexao, $sql_post);

$sql_insert = "INSERT INTO nota_trabalho (code, bimestre, discipline, nota) VALUES ('$code_aluno', '$bimestre', '$nota' )";

mysqli_query($conexao, $sql_insert);

echo "<script language='javascript'>window.location='';</script>";
}
}var_dump($disciplina)

?>
    
asked by anonymous 16.02.2017 / 04:22

1 answer

1

In this section:

INSERT INTO nota_trabalho (code, bimestre, discipline, nota)
VALUES ('$code_aluno', '$bimestre', '$nota' )

The value corresponding to discipline is missing. See:

INSERT INTO nota_trabalho (code, bimestre, discipline, nota)
VALUES ('$code_aluno', '$bimestre', '$disciplina' , '$nota' )
    
16.02.2017 / 11:45