Tuesday, October 1, 2013

How to use mysqli_query - PHP

How to use mysqli_query - PHP

Okay so I have a file that contains all the information for my database,
then I have a file that uses this information and a separate function that
calls the database. 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? Because mysqli_query expects to things, the query and 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;
}
}

No comments:

Post a Comment