[英]CodeIgniter not correctly performing a sql query
In Ci I'm getting the following error: 在Ci中,出现以下错误:
A Database Error Occurred
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 '', '1f37540fc54292b018a9e993da38cb5647dc5587', NOW(), '0')' at line 1
INSERT INTO users (userpid, Email, Password, dateTimeRegistered, isLeader) VALUES ('147344f0e33367f9e6', erf', '1f37540fc54292b018a9e993da38cb5647dc5587', NOW(), '0')
Filename: C:\Workspace\htdocs\Misc-2\DruvlaCi-1\system\database\DB_driver.php
Line Number: 330
But everything seems to be right in the SQL query. 但是在SQL查询中,一切似乎都是正确的。 Below is my query, any thoughts?
以下是我的查询,有什么想法吗?
$query = $this->db->query("INSERT IGNORE INTO users (userpid, Email, Password, dateTimeRegistered, isLeader) VALUES ('{$idgen}', {$postedEmail}', '{$hashedPass}', NOW(), '0')");
You're forgetting the opening single quote for the email column 您忘记了电子邮件列的开头单引号
Try this instead 试试这个
$query = $this->db->query("INSERT IGNORE INTO users (userpid, Email, Password, dateTimeRegistered, isLeader) VALUES ('{$idgen}', '{$postedEmail}', '{$hashedPass}', NOW(), '0')");
Uhm, and please, use this syntax for inserting instead: 嗯,请改用这种语法插入:
http://codeigniter.com/user_guide/database/active_record.html#insert http://codeigniter.com/user_guide/database/active_record.html#insert
works so much safer. 安全得多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.