当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Can't solidify login using codeigniter

问题描述:

been recoding my site using code igniter. I am having some quirks with my seemingly sensical scripts.

please note that I am aware of not encrypting passwords but am just clear texting until I can get signed in and will implement as step 2

Error Number: 1064

You have an error in your SQL syntax; check the manual that

corresponds to your MySQL server version for the right syntax to use

near '@gmail.com && password = Password LIMIT 1' at line 1

SELECT id FROM users WHERE email = [email protected] && password =

Password LIMIT 1

HERE is my code along with an explanation of my problems.

Thanks in advance.

网友答案:

You need to have quotes around Password and Email on your select statement.

The following should work for your case:

$email = mysql_real_escape_string($this->input->post('email'));
$password = mysql_real_escape_string($this->input->post('password'));
$query = $this->db->query('SELECT id FROM users WHERE email = "' . $email . '" && password = "' . $password . '" LIMIT 1');
网友答案:

Try replacing the single quotes with double quotes on your $this->input->post() sections. I think you're escaping out the variables.

网友答案:

In CI, you're supposed to do it this way:

$this->db->select("id");
$this->db->from("users");
$this->db->where("email", $this->input->post('email'));
$this->db->where("password", $this->input->post('password'));
$this->db->limit(1);
$query = $this->db->query();
分享给朋友:
您可能感兴趣的文章:
随机阅读: