-1
This system and to make banking operations the user will have to make the deposit only he enters a value that he wants to deposit and in the bank he will have to add with the current balance only that is not working. he’s putting a number 7 and he’s not making the sum
<?php
$idConta=$_POST['idConta'];
$valor=$_POST['valor'];
$consu= mysql_query("select saldo from conta where idConta=$idConta");
$saldoatual = $consu + $valor;
$up = mysql_query("UPDATE conta SET saldo='$saldoatual' WHERE idConta=$idConta");
?>
You don’t even need the
SELECT
, can do right in theUPDATE
in this wayUPDATE conta SET saldo = saldo + '$saldoatual' WHERE idConta=$idConta
– Roberto de Campos
mysql_query
returns a reference to a result set, instead of the result set itself, then you stop$consu
will have something likeResource id #3
. You need to call a function like mysql_fetch_array or mysql_fetch_assoc to read the result itself of the result set object (and what you get is an array). This value: Resource id #3 is the return of a query, indicating tb the position of the memory in which it was allocated– user60252
Learn more about Resource in https://answall.com/questions/90764/o-que-%C3%A9-a-type-Resource-in-php-to-serve/90771#90771
– user60252