mysql - Fatal error: Call to a member function

Trying to Create a login screen and I get an Error

Fatal error: Call to a member function prepare() on a non-object in C:\xampp\htdocs\login\classes\Mysql.php on line 19


require_once 'includes/constants.php';

class Mysql {
    private $conn;

    function __construct() {
        $this->conn = new mysqli (DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die('There was a problem connecting to the database.');  

    function verify_Username_and_Pass($un, $pwd) {

        $query = "SELECT *
                    FROM users
                    WHERE username = ? AND password = ?
                    LIMIT 1";

        if($stmt = $this->conn->prepare($query)) {
            $stmt->bind_param('ss', $un, $pwd);

            if($stmt->fetch()) {
                return true;


// Define constants here

define('DB_SERVER', '');
define('DB_USER', 'user');
define('DB_PASSWORD', 'pass');
define('DB_NAME', 'membership');


There's no object 'mysql' in php. Try mysqli

make sure that the "user" has a grant to the database membership. here it is

grant all on membership.* to user@localhost identified by 'pass'

Need Your Help

How to find the file causing a mysql syntax error

mysql syntax

I'm a newbie. I just set up Ubuntu to run on my Chromebook (via Crouton) last week and am currently in the process of setting up several Wordpress sites on localhost. I successfully installed a new

show data in textview from sqlite database in android

java android sqlite

i'm trying to show data in textviews from database in android but it show run time erroe.. i am create database file as..