php - mysql - Fatal error: Call to a member function -
trying create login screen , error
fatal error: call member function prepare() on non-object in c:\xampp\htdocs\login\classes\mysql.php on line 19
<?php 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 problem connecting database.'); } function verify_username_and_pass($un, $pwd) { $query = "select * users username = ? , password = ? limit 1"; if($stmt = $this->conn->prepare($query)) { $stmt->bind_param('ss', $un, $pwd); $stmt->execute(); if($stmt->fetch()) { $stmt->close(); return true; } } } }
constants.php
<?php // define constants here define('db_server', '192.168.2.50:3306'); define('db_user', 'user'); define('db_password', 'pass'); define('db_name', 'membership');
there's no object 'mysql' in php. try mysqli
Comments
Post a Comment