Error Number: 1054 Unknown column 'username='xc'' in 'where clause' SELECT `id`, `username`, `password` FROM (`users`) WHERE `username='xc'` AND `password='b587c9a76c9cd8dfc40a757616c1e47d'` LIMIT 1 Filename: C:\xampp\htdocs\rpo\system\database\DB_driver.php Line Number: 330
代码:
function login($username,$password) {
$this->db->select('id,username,password');
$this->db->from('users');
$this->db->where('username='."'".$username."'");
$this->db->where('password='."'".MD5($password)."'");
$this->db->limit(1);
$query=$this->db->get();
if($query->num_rows()==1) {
return $query->result();
} else {
return false;
}
最佳答案
试试这个
SELECT `id`, `username`, `password`
FROM `users`
WHERE `username`='xc'
AND `password`='b587c9a76c9cd8dfc40a757616c1e47d' LIMIT 1
您应该在列名称周围使用反引号,而不是整个句子或整个 where 子句。
将你的行更改为:
$this->db->where('username' , $username );
$this->db->where('password' , MD5($password) );
关于php - 发生数据库错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21349484/