Alright. So basically. Here's my code.
login.php
require_once("./libs/db_cxn.php");
$cxn = new newConnection();
$stmt = "SELECT users.username FROM users WHERE username=$username AND password=MD5($password)";
$qry = \mysqli_prepare($cxn, $stmt);
$res = mysqli_execute($qry);
db_cxn.php
class newConnection{
function __construct(){
$conf = array(
"host" => "localhost",
"username" => "root",
"password" => "root",
"dbname" => "db_BookWorm",
"port" => ini_get("mysqli.default_port"),
"socket" => ini_get("mysqli.default_socket"),
"prefix" => "bWorm_"
);
$cxn = new mysqli($conf["host"], $conf["username"], $conf["password"], $conf["dbname"]);
if ($cxn->connect_errno){
\printf("Connection failed: %s\n", $cxn->connect_error);
exit();
}
}
function _destruct(){
mysqli_close($this);
}
}
I have error reporting on, and the following error message is given whenever i attempt to run that code
Warning: mysqli_prepare() expects parameter 1 to be mysqli, object given in \\MORIARTY\HOME\15\5CBA2901\Desktop\comp_proj\project\www\login.php on line 34
Any clues on how to fix this? I have created this connection class due to how frequent i will be opening connections, and figured it'd save time and grief on my part. Any help would be appreciated!