gpt4 book ai didi

php - 发生数据库错误

转载 作者:太空宇宙 更新时间:2023-11-03 12:17:46 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com