I am getting an error when running a certain method in PHP. I looked into it and it seems I need the mysqlnd driver. I understand I have to configure this in the php.ini file but since I have shared hosting with GoDaddy, I don't have access to the ini file. I called GoDaddy and they basically said, you have to create your own. My question is, where is the ini file placed in my case? would I need to create a php.ini file or a php5.ini. Also, how would I write the settings in the file, I have never worked with an ini file and I don't really know how it looks.
DB_Functions.php code:
<?php
class DB_Functions {
private $con;
function __construct() {
require_once 'DB_Connect.php';
$db = new DB_Connect();
$this->con = $db->connect();
}
function __destruct() {
}
public function storeUser($name, $email, $password) {
$uuid = uniqid('', true);
$hash = $this->hashSSHA($password);
$encrypted_password = $hash['encrypted'];
$salt = $hash['salt'];
$stmt = $this->con->prepare("INSERT INTO users(unique_id, name, email, encrypted_password, salt, created_at) VALUES(?, ?, ?, ?, ?, NOW())");
$stmt->bind_param('sssss', $uuid, $name, $email, $encrypted_password, $salt);
$result = $stmt->execute();
$stmt->close();
if ($result) {
$stmt = $this->con->prepare("SELECT * FROM users WHERE email = ?");
$stmt->bind_param('s', $email);
$stmt->execute();
$user = $stmt->get_result()->fetch_assoc();
$stmt->close();
return $user;
} else {
return false;
}
}
public function getUserByEmailAndPassword($email, $password) {
$stmt = $this->con->prepare("SELECT * FROM users WHERE email = ?");
$stmt->bind_param('s', $email);
if ($stmt->execute()) {
$user = $stmt->get_result()->fetch_assoc();
$stmt->close();
$salt = $user['salt'];
$encrypted_password = $user['encrypted_password'];
$hash = $this->checkhashSSHA($salt, $password);
if ($encrypted_password == $hash) {
return $user;
}
} else {
return NULL;
}
}
public function getUserByNameAndPassword($name, $password) {
$stmt = $this->con->prepare("SELECT * FROM users WHERE name = ?");
$stmt->bind_param('s', $name);
if ($stmt->execute()) {
$user = $stmt->get_result()->fetch_assoc();
$stmt->close();
$salt = $user['salt'];
$encrypted_password = $user['encrypted_password'];
$hash = $this->checkhashSSHA($salt, $password);
if ($encrypted_password == $hash) {
return $user;
}
} else {
return NULL;
}
}
public function doesUserEmailExist($email) {
$stmt = $this->con->prepare("SELECT email FROM users WHERE email = ?");
$stmt->bind_param('s', $email);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows > 0) {
$stmt->close();
return true;
} else {
$stmt->close();
return false;
}
}
public function doesUserNameExist($name) {
$stmt = $this->con->prepare("SELECT name FROM users WHERE name = ?");
$stmt->bind_param('s', $name);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows > 0) {
$stmt->close();
return true;
} else {
$stmt->close();
return false;
}
}
public function hashSSHA($password) {
$salt = sha1(rand());
$salt = substr($salt, 0, 10);
$encrypted = base64_encode(sha1($password . $salt, true) . $salt);
$hash = array('salt' => $salt, 'encrypted' => $encrypted);
return $hash;
}
public function checkhashSSHA($salt, $password) {
$hash = base64_encode(sha1($password . $salt, true) . $salt);
return $hash;
}
}
?>
I am getting error on two lines that use the same code.
$user = $stmt->get_result()->fetch_assoc();