I know this has been asked many times before so I apologize but here's the php file that's generating the error on the "if($stmt = $this->conn->prepare($query))" line:
<?php
require_once 'includes/constants.php';
class Mssql {
private $conn;
function __construct() {
$dbServer = DB_SERVER;
$dbName = DB_NAME;
$conn = new PDO( "sqlsrv:Server=$dbServer;Database=$dbName", NULL, NULL);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
if ( $conn === false ) {
echo "Could not connect.\n";
die;
}
}
function verify_Username_and_Pwd($un, $pwd) {
$query = "SELECT * FROM users WHERE username = ? AND password = ? LIMIT 1";
if($stmt = $this->conn->prepare($query)) {
$stmt->bind_param('ss', $un, $pwd);
$stmt->execute();
if($stmt->fetch()) {
$stmt->close();
return true;
}
}
}
}
And here's the constants.php file that's required:
<?php
// Define constants here
define("DB_SERVER", "localhost");
define("DB_NAME", "testdb");
I could really use some help in solving this, thanks.