I have this code:
class database{
    var $conn;
    function connect($server,$host_username,$host_password,$host_database){
        $server = 'localhost';
        $host_username = 'root';
        $host_password = '';
        $host_database = 'e-vent system db';
        $conn= new mysqli($server,$host_username,$host_password,$host_database);
        if ($conn->connect_error){
            die("db connection error:". $conn->connect_error);
        }
    }
    function read_db($table,$condition){
        $read="SELECT * FROM ".$table." ".$condition;
        $read_result=$conn->query($read);
        if(!$read_result){
            echo "select error:". mysqli_error($conn);
        }
        return $result;
    }
}
And I get this error:
Notice: Undefined variable: conn in C:\xampp\htdocs\E-vent\database.php on line 19
How can I make the $conn variable visible to the read_db function?
 
     
     
     
     
    