title: How to put variable within mysql command? php
body: <p>got a little problem here with php. I got a simple calculation system, in which there are fields balance, trtype (long version transaction type), tramt(amount of that specific transaction), and finalbalance, which is the balance AFTER the operation.
  It shows up as a table and it has the list of all transactions a user had. So i make a form where the ""employees""(theres only me), can fill out the form like date trans type and so on. To avoid any kind of miscalculations, i dont want the ""employees"" to put the finalbalance field by themselves. I want the computer to do it. And the finalbalance is always same what happened after the transaction. When new transaction happens, it creates a new number and keeps the old one. It is kind of messy, and im 99% sure this is not the best approach, but would appriciate any help.</p>
  
  <pre><code>$AS = $CONNECT-&gt;prepare('UPDATE acc balance = CONCAT(balance + ?,"&lt;br&gt;"), WHERE username = ? '))
  $AS-&gt;bind_param('ss', $_POST['balance'],$_POST['ac']);
  $AS-&gt;execute();
  $AS-&gt;store_result();
  $AS-&gt;close();
  $AS2 = $CONNECT-&gt;prepare('SELECT finalbalance FROM accounts WHERE username = ?');
  $AS2-&gt;bind_param('s', $_POST['acc']);
  $AS2-&gt;execute();
  $AS2-&gt;bind_result($fnb);
  $AS2-&gt;store_result();
  $AS3 = $CONNECT-&gt;prepare('UPDATE accounts SET finalbalance = CONCAT(finalbalance+.$fnb.,"&lt;br&gt;") WHERE username = ?');
  $AS3-&gt;bind_param('s', $_POST['acc']);
  $AS3-&gt;execute();
  $AS3-&gt;store_result();
  $AS3-&gt;close();
  </code></pre>
  
  <p>I do this code, but this gives me an error Stack trace {main} thrown, which usually means i screwed up in my mysql command, so im guessing it didnt get the variable. Thanks for reading and help.</p>