showing a little more code would be helpful, for example:
[php] public function create($data) {
if (is_array($data)) { // If statement probably not needed:
/* Secure the Password by hashing the user's password. */
$data['password'] = password_hash($data['password'], PASSWORD_BCRYPT, array("cost" => 15));
try {
/* Set the query variable */
$this->query = 'INSERT INTO users (username, password, confirmation_code, security_level, first_name, last_name, email, date_added) VALUES (:username, :password, :confirmation_code, :security_level, :first_name, :last_name, :email, NOW())';
/* Prepare the query */
$this->stmt = $this->pdo->prepare($this->query);
/* Execute the query with the stored prepared values */
$this->result = $this->stmt->execute([
':username' => $data['username'],
':password' => $data['password'],
':confirmation_code' => $data['confirmation_code'],
':security_level' => $data['security_level'],
':first_name' => $data['first_name'],
':last_name' => $data['last_name'],
':email' => $data['email']
]); // End of execution:
if ($this->result) {
return "Data was successfully entered in table";
}
} catch (PDOException $error) {
// Check to see if name is already exists:
$errorCode = $error->errorInfo[1];
if ($errorCode == MYSQL_ERROR_DUPLICATE_ENTRY) {
error_log("Duplicate Name was Enter", 1, "[email protected]");
} else {
throw $error;
}
}
} // End of main if-statement:
}[/php]
that is just an example and wrap it around php tags that you’ll find in the editor.