-2
Speak cooler! I need a help.
I’m creating some screens with PHP 7.4 + Mysqli + Apache, running on an Ubuntu 18.04.
I have a file/script registro_serra.php
, in it I capture variables to insert in the table corte_torete
with the method $_GET
a Form. As follows:
<form action="registro_serra.php" method="GET">
<div class="form-group">
<label>Comprimento do Torete 1</label>
<select class="form-control text-center" id="comprimento_torete" name="comprimento_torete">
<option value="11">11 Centímetros</option>
<option value="">...</option>
<option value="20">20 Centímetros</option>
</select>
I’m able to capture these variables and insert them into B.D. As follows:
if(isset($_GET['btn-gravar-torete1'])):
// Gravando na tabela
$gravatt = mysqli_query ($connect, "INSERT INTO corte_torete (nro_lote...volume_torete) VALUES ('$lote3'...'$volume_tt')");
mysqli_close($connect);
In this same file, I need to capture the same values to insert into the same table. In another set identified as name 'torete2'.
<div class="form-group">
<label>Comprimento do Torete 2</label>
<select class="form-control text-center" id="comprimento_torete_2" name="comprimento_torete_2">
<option value="11">11 Centímetros</option>
<option value="">...</option>
<option value="20">20 Centímetros</option>
</select>
Send it to B.D the same way
if(isset($_GET['btn-gravar-torete_2'])):
// Gravando na tabela
$gravatt_2 = mysqli_query ($connect, "INSERT INTO corte_torete (nro_lote...volume_torete) VALUES ('$lote3_2'...'$volume_tt_2')");
mysqli_close($connect);
Both insert cute, but only 1 at a time, I need to insert up to 9 times so, on the same page, for the same table. If I delete the record by Phpmyadmin, it allows a new insertion... I tried with $_POST, it’s still. Any suggestions?
I enabled to show the errors, and when it does not write, returns Error: Query was Empty
Thanks! It’s my first post here :)
Thanks for the help Pedro, in the meantime I managed to solve! : D One of the changes was to use $_POST instead of $_GET The other was to implement other "debug" functions as an example
code
if ($connect->multi_query($gravatt2) === TRUE) { echo "Recorded."; } Else { echo "Error: " . $gravatt2 . " " . $connect->error; }code
So I discovered that I was trying to insert a duplicate value into a field defined as "Primary" and "auto increment", I removed these properties, so B.D allowed me to insert duplicate them...– WoNath
@Jonathanwolffandrade, how nice that you managed to solve yourself, good studies!
– Pedro Henrique