I have defined my connection in my method. However, I want to be able to create an instance of this connection for use on a login page.
Normally the way I do this on pages such has insert, select etc.
$con = new dbclass(); //class where my methods are housed
$con-> createcon(); //create con has the connection handler, ($con=mysqli_connect(x.x.x.x)
Fair enough, I use this a lot. However, I'm not having any luck with this procedure on my login page. It appears inadequate. Errors returned are :
Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, object given in C:\xampp\htdocs\a\login.php on line 103
Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, object given in C:\xampp\htdocs\a\login.php on line 104
Warning: mysqli_query() expects parameter 1 to be mysqli, object given in C:\xampp\htdocs\a\login.php on line 109
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\a\login.php on line 111
This is an example piece of code that returns an error :
$user = mysqli_real_escape_string($con, $user);
To date I have only used real_escape_string on an update method within a class. I managed to satisfy the connection handler requirement on real_escape_string by doing this
$esc_id = mysqli_real_escape_string($this->conn, $id);
So my question is, do I somehow need to create an instance on my login page. And if so, how?