我一直从这个简单的mysql语句中得到以下错误,我不明白为什么。我敢肯定这是显而易见的事情。
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());
}
}给出错误:'field list‘中的未知列'payday’
这是我的表单代码:
<form action=process.php method=post>
£
<input type=text name=predec size=7>
. 
<input type=text name=dec size=4 value=00>
<br />
<select name=category>
<option value=payday>Payday</option>
</select>
<input type=text name=notes size=20>
<input type=submit name=in value=Deposit>
<input type=submit name=out value=Withdraw>
</form> 数据库表accounts包含以下字段:
id,整型主A_I
balancein,十进制10,2
平衡输出,十进制10,2
当前余额,十进制10,2
类别,varchar 50
备注,varchar 255
日期,时间戳
...in该订单
发布于 2013-03-30 03:47:13
基本上,sql告诉您,您在insert中引用了数据库中未定义的列。提供您的表结构或确保列名与您在数据库中定义的完全相同。HTH。
https://stackoverflow.com/questions/15710397
复制相似问题