Friends, I'm doing pro bono work for a public service, and I've been trying to figure out what's wrong with my code for days. If anyone can help me, thank you very much.
O formulário é esse:
<html>
<style>
::-webkit-input-placeholder { color:#CDCDCD; }
input:-moz-placeholder { color:#CDCDCD; }
textarea:-moz-placeholder { color:#CDCDCD; }
</style>
<form name="saque" action="https://equadsaude.000webhostapp.com/bancodados_atualizar.php" method="POST">
<table>
<tr>
<td>Processo</td> </tr>
<tr>
<td><input name="n1" placeholder="somente algarismos"></td>
</tr>
<tr>
<td>Valor total sacado</td> </tr>
<tr>
<td><input name="n4" placeholder="00000.00"></td>
</tr>
<tr>
<td>Observações e Data </td> </tr>
<tr>
<td><input type="text" name="n3" ></td>
</tr>
<tr>
<td col span="3"><input type="submit" name="submit" value="Atualizar"></td>
</tr>
</table>
</form>
</html>
And the .php file (which is on the local server) that it should call is this:
<?php
$conectar = new mysqli("localhost","id1019345_dados_zzzz","xxxx", "id1019345_sobras") or die(mysqli_error());
$processo = $_POST[ 'n1' ] ;
$valor_sacado = $_POST[ 'n4' ] ;
$observacoes = $_POST[ 'n3' ] ;
//variavel de teste do POST no banco de dados
$teste = mysqli_query($conectar, "SELECT 'id' FROM 'Tab_Index' WHERE 'Processo' = '$processo' ");
while (mysqli_num_rows($conectar, $teste) == 0)
{
echo "<p>Não existe o registro informado. Verifique novamente no Banco de Dados.</p>"; exit(mysqli_error());
}
//variavel para cálculo do Valor da Sobra no banco de dados
$sql_seleciona = mysqli_query($conectar, "SELECT 'Valor_sobra' FROM 'Tab_Index' WHERE 'Processo' = '$processo' ");
while ($query_row = mysqli_fetch_assoc($conectar, $sql_seleciona))
{
foreach($query_row as $key => $value)
{
$resultado = $value-$valor_sacado;
}
}
//variavel para selecao das Observacoes no banco de dados
$sql_seleciona2 = mysqli_query ($conectar, "SELECT 'Observacoes' FROM 'Tab_Index' WHERE 'Processo' = '$processo' ");
while ($query_row2 = mysqli_fetch_assoc($conectar, $sql_seleciona2))
{
foreach($query_row2 as $key => $value)
{
$resultado2 = $query2."/". $observacoes;
}
}
//Update do banco de dados
$sql_alterar = mysqli_query($conectar, "UPDATE 'Tab_Index' SET 'Valor_sobra' = '$resultado1', 'Observacoes' = '$resultado2' WHERE 'Processo' = '$processo' ");
if ( isset ($sql_alterar) )
{
print "<h3> Valor da sobra atualizado com sucesso </h4>\n" ;
}
else
{
print "<h3> Erro ao atualizar </h4>\n" ;
}
?>
The problem is that the message "There is no record entered, please check the database again", which I warned you if you did not find anything in the database. But even when I put a Process number that exists in the database, it keeps giving that information. And if I remove this conference from the script, the final message "Replace value successfully updated" appears as if the database update had occurred, but when I check the database, nothing has changed.
Impression I have is that the interaction with the database is not occurring, for some reason I do not know what it is.
The table in the DB has 4 columns: id, Process (BIGINT), Value_sobra (DECIMAL 7,2), Remarks (VARCHAR). HOST: localhost USERNAME: id1019345_dados_zzzz PASSWORD: xxxx DB: id1019345_sobras