What is the error in this MySQL-PHP code?

-1

I am trying to extract the value of a form so that it is added to a value of a row in a table in mysql, by means of a string that extracts the value of a query and this value is used to update the information of the record, but it does not. What could be the error?

$SQL="select Cantidad + ".$_POST['Cantidad']." from gasolina where Gasolina = \"".$_POST['Gasolina']."\"";
                 $resultado = mysql_query($SQL, $idconexion); 
                 $fila = mysql_fetch_row($resultado);
                 $SQL="UPDATE gasolina SET Cantidad=\"".$fila[0]."\" WHERE where Gasolina = \"".$_POST['Gasolina']."\"";
                }
    
asked by Wilhelm Serrano 02.05.2018 в 06:09
source

1 answer

0

It seems that there is an error in the query, you have written twice the clause where :

$SQL="select Cantidad + ".$_POST['Cantidad']." from gasolina where Gasolina = \"".$_POST['Gasolina']."\"";
$resultado = mysql_query($SQL, $idconexion); 
$fila = mysql_fetch_row($resultado);
$SQL="UPDATE gasolina SET Cantidad=\"".$fila[0]."\" WHERE where Gasolina = 
                                                    ^^^^^^^^^^^
\"".$_POST['Gasolina']."\"";      

Tests with this:

 $SQL="UPDATE gasolina SET Cantidad=\"".$fila[0]."\" WHERE Gasolina =\"".$_POST['Gasolina']."\"";  

NOTE

This answer tries to help to discover what is the possible cause to which your query does not work, I do not know if you do it in this way for some type of restriction or particular requirement, if not, I suggest that you pay attention to the Recommendation that makes you gbianchi in your comment and explore that possibility.

    
answered by 02.05.2018 в 08:33