Hello guys,
I have been trying to fix these errors, but it wont work. This are the errors im getting
Warning: mysqli_query() expects parameter 1 to be mysqli, object given in /home/335456/public_html/hoi/class.user.php on line 35

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/335456/public_html/hoi/class.user.php on line 36
This is the code where the error appears, does anyone know what i'm doing wrong?

  /*** for login process ***/
  public function check_login($emailusername,$password){ 
  $password = md5($password);
  $sql2="SELECT userid from users WHERE username='$emailusername' or email='$emailusername' and password='$password'";

  //checking if the username is available in the table
  $result = mysqli_query($this->db,$sql2);
  $user_data = mysqli_fetch_array($result);
  $count_row = $result->num_rows;
$DB_host = "mydetails";
$DB_user = "mydetails";
$DB_pass = "mydetails";
$DB_name = "mydetails";

try
{
     $DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass);
     $DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
     echo $e->getMessage();
}


include_once 'class.user.php';
$user = new USER($DB_con);

and this is the function

 private $db;

   public function __construct($DB_con)
    {
      $this->db = $DB_con;
    }

Connecting with PDO and then trying to query with MySQLi won't work. Be consistent, choose one.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.