This is my code and I am facing this error
Call to a member function prepare() on null in I think my classes are alright but there is an error and I don't know how to make this code running
<?php
/*$servername = "localhost:3307";
$username = "root";
$password = "";
$dbname = "motorway";*/
class BaseConnect {
private $conn;
function __construct() {
}
// Create connection
function connect() {
$conn = new mysqli("localhost:3307", "root", "", "motorway");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
return $this->conn;
}
}
class Database {
private $conn;
function __construct() {
$db = new BaseConnect();
$this->conn = $db->connect();
}
function Enterdata($name, $phone, $email, $password) {
$pass = md5($password);
$sql = $this->conn->prepare("INSERT INTO 'user'('name', 'phone', 'email', 'pass')
VALUES(?, ?, ?);");
$sql->bind_param("ssss", $name, $phone, $email, $pass);
if ($sql->execute()) {
return 1;
} else {
return 2;
}
}
}