简体   繁体   中英

Unknown column 'Username' in 'where clause'

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);

I am getting an error:

Unknown column 'Username' in 'where clause'

How can I solve it?

The asset and withdrawal tables do not have a column called Username. So add that column to these tables or change WHERE condition in the sql statement related to these tables.These sql statements refer to the Username column in the WHERE clause that does not exist:

SELECT * FROM **asset** WHERE **Username**

SELECT * FROM **withdrawal** WHERE **Username**

New CREATE statements including Username column:

    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; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM