Note that there are some explanatory texts on larger screens.

plurals
  1. POMYSQL - INSERT error, unknown column in field list
    text
    copied!<p>i keep getting the following error from this simple mysql statement and i cant see why. im sure its something obvious.</p> <pre><code>require_once("connect.php"); $query = mysql_query("SELECT * FROM accounts ORDER BY id DESC LIMIT 1"); $row = mysql_fetch_assoc($query); $balanceold = $row['balance']; $difference = $_POST['predec'].".".$_POST['dec']; $category = $_POST['category']; $notes = $_POST['notes']; if(isset($_POST['in'])){ $balancenew = $balanceold + $difference; $query = mysql_query("INSERT INTO accounts(currentbalance, balancein, category, notes) VALUES (".$balancenew.", ".$difference.", ".$category.", ".$notes.")"); if($query){ header("Location: budget.php"); } else{ die(mysql_error()); } } </code></pre> <p>gives error: Unknown column 'payday' in 'field list'</p> <p>here is my form code:</p> <pre><code>&lt;form action=process.php method=post&gt; &amp;pound; &lt;input type=text name=predec size=7&gt; . &lt;input type=text name=dec size=4 value=00&gt; &lt;br /&gt; &lt;select name=category&gt; &lt;option value=payday&gt;Payday&lt;/option&gt; &lt;/select&gt; &lt;input type=text name=notes size=20&gt; &lt;input type=submit name=in value=Deposit&gt; &lt;input type=submit name=out value=Withdraw&gt; &lt;/form&gt; </code></pre> <p>database table"accounts" contains the following fields:</p> <p>id, int primary A_I</p> <p>balancein, decimal 10,2</p> <p>balanceout, decimal 10,2</p> <p>current balance, decimal 10,2</p> <p>category, varchar 50</p> <p>notes, varchar 255</p> <p>date, timestamp</p> <p>...in that order</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload