I have a file that contains all the information for my database. I have another file that uses this information. And I have a function that is suppose to gather information from the database but I need to use mysqli_query.
How do I do this?
mysqli_query expects two things:
- the query
- the connection to the database
But my connection to the database is a separate function.
private $db;
//put your code here
// constructor
function __construct() {
require_once 'DB_Connect.php';
// connecting to database
$this->db = new DB_Connect();
$this->db->connect();
}
// destructor
function __destruct() {
}
public function isUserExisted($email) {
$result = mysqli_query(
What goes here?
,"SELECT email from users WHERE email = '$email'");
$no_of_rows = mysqli_num_rows($result);
if ($no_of_rows > 0) {
// user existed
return true;
} else {
// user not existed
return false;
}
}