The purpose of this script is to allow the user to add "money" to their account and then withdraw the money. This whole task is a fictitious one for school so i'm not worried about security or using real money or anything like that.
so far the user has the ability to add money. But I cannot get the withdraw to work.
$funds = $_POST['funds'];
$withdraw_or_add = $_POST['list'];
if($withdraw_or_add == "add"){
$sql = "UPDATE users ". "SET userFunds = $funds ". "WHERE userId = 1";
} else {
$info = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE userId = '1'"));
$new_fund == $info['userFunds'] - $funds;
$sql = "UPDATE users ". "SET userFunds = $new_fund ". "WHERE userId = 1";
}
This is the code I have written for this section. When i used it on the server i get this message in return.
Could not update data: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE userId = 1' at line 1
My knowledge of PHP is not fantastic. So any help would be much appreciated.