mysql_select_db($database_binary, $binary);
$query_account = sprintf("SELECT * FROM users WHERE Username = %s", GetSQLValueString($colname_account, "text"));
$account = mysql_query($query_account, $binary) or die(mysql_error());
$row_account = mysql_fetch_assoc($account);
$totalRows_account = mysql_num_rows($account);
$maxRows_trade = 20;
$pageNum_trade = 0;
if (isset($_GET['pageNum_trade'])) {
$pageNum_trade = $_GET['pageNum_trade'];
}
$startRow_trade = $pageNum_trade * $maxRows_trade;
$colname_trade = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_trade = $_SESSION['MM_Username'];
}
mysql_select_db($database_binary, $binary);
$query_trade = sprintf("SELECT * FROM asset WHERE Username = %s", GetSQLValueString($colname_trade, "text"));
$query_limit_trade = sprintf("%s LIMIT %d, %d", $query_trade, $startRow_trade, $maxRows_trade);
$trade = mysql_query($query_limit_trade, $binary) or die(mysql_error());
$row_trade = mysql_fetch_assoc($trade);
if (isset($_GET['totalRows_trade'])) {
$totalRows_trade = $_GET['totalRows_trade'];
} else {
$all_trade = mysql_query($query_trade);
$totalRows_trade = mysql_num_rows($all_trade);
}
$totalPages_trade = ceil($totalRows_trade/$maxRows_trade)-1;
$maxRows_withdrawreq = 10;
$pageNum_withdrawreq = 0;
if (isset($_GET['pageNum_withdrawreq'])) {
$pageNum_withdrawreq = $_GET['pageNum_withdrawreq'];
}
$startRow_withdrawreq = $pageNum_withdrawreq * $maxRows_withdrawreq;
$colname_withdrawreq = "-1";
if (isset($_SESSION['Username'])) {
$colname_withdrawreq = $_SESSION['Username'];
}
mysql_select_db($database_binary, $binary);
$query_withdrawreq = sprintf("SELECT * FROM withdrawal WHERE Username = %s", GetSQLValueString($colname_withdrawreq, "text"));
$query_limit_withdrawreq = sprintf("%s LIMIT %d, %d", $query_withdrawreq, $startRow_withdrawreq, $maxRows_withdrawreq);
$withdrawreq = mysql_query($query_limit_withdrawreq, $binary) or die(mysql_error());
$row_withdrawreq = mysql_fetch_assoc($withdrawreq);
我收到错误:
'where子句'中的未知列'用户名'
我该如何解决?
答案 0 :(得分:1)
资产和提款表没有名为Username的列。因此,将该列添加到这些表中或更改与这些表相关的sql语句中的WHERE条件。这些sql语句引用WHERE子句中不存在的Username列:
SELECT * FROM **asset** WHERE **Username**
SELECT * FROM **withdrawal** WHERE **Username**
新的CREATE语句,包括用户名列:
CREATE TABLE asset ( Asset varchar(100) NOT NULL, optiontype varchar(200)
NOT NULL,
Invested varchar(200) NOT NULL, Username varchar(100) NOT NULL,
Entry Rate varchar(200) NOT NULL, Rate varchar(200) NOT NULL, Entry Time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, Expiration Time varchar(200) NOT NULL, Status varchar(200) NOT NULL, Returns varchar(200) NOT NULL, Customer varchar(200) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=armscii8;
CREATE TABLE withdrawal ( id varchar(100) NOT NULL, Username varchar(100) NOT NULL,
Date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, Customer varchar(200) NOT NULL, Amount varchar(100) NOT NULL, currency varchar(100) NOT NULL, email varchar(100) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=armscii8;