Help with PHP OOP PDO
Guys, I really need your help! I'm seriously stuck in my project...
I learn the OOP in PHP, now I build a LOGIN & RESITER system but, when I try insert new user into the DB I get an error:
Fatal error: Uncaught exception 'Exception' with message 'SQLSTATE[42000]: Syntax error or access violation: 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 'group) VALUES ('NewUserName', '68f7ad648943bf04ec61ae61cf8b3e934549eb9de8220cb18' at line 1' in C:\xampp\htdocs\login\register.php:54 Stack trace: #0 {main} thrown in C:\xampp\htdocs\login\register.php on line 54
class Users {
private $db;
public function __construct(){
$this->db = new Database();
}
public function create($fields = []){
$arr = array_values($fields);
if (!$this->db->insertRow("INSERT INTO users (username, password, salt, fullname, joined, group) VALUES (?, ?, ?, ?, ?, ?)", $arr)) {
throw new Exception('There was a problem creating an account!');
}
}
}
public function insertRow($query, $params){
try {
$stmt = $this->datab->prepare($query);
$stmt->execute($params);
return TRUE;
} catch (Exception $e){
throw new Exception($e->getMessage());
}
}
Array ( [0] => NewUserName [1] => 0178890e573c0aeb6875def9231230defaf021f2e1747ae40d8d384a9d1eb0d2 [2] => ùë....OÉesæ":Æ'·\áè!Èû0ISIõòá1 [3] => UserFullName [4] => 2015-07-05 21:15:39 [5] => 1 )
I tried anything that I know, I have no idea what to do.... I'm really frustrated...
Can anyone help me please? I will very that you 4 all your help!
-
chickahoona -
Thanks - 1 reply
{{ DiscussionBoard.errors[10153385].message }}-
exma -
Thanks
{{ DiscussionBoard.errors[10154085].message }} -
-