Call to a member function query() on a non-object
Hi,
I'm building an object to get results from a database. This is the code:
<?php
class bf_conn
{
// define attributes
...
function __construct()
{
$bf_connect = new mysqli($this->sql_host, $this->sql_user, $this->sql_pass, $this->sql_dbase);
}
function db_result()
{
$bf_result = $this->bf_connect->query($this->bf_query);
return $bf_result;
}
}
// connect
$check_db = new bf_conn;
// query
$login_query = "SELECT * FROM login_log";
$check_db->bf_query = $login_query;
// query exec
$login_result = $check_db->db_result();
// count results
$check1 = $login_result->num_rows;
// display
echo $check1;
?>
I get the following error: Call to a member function query() on a non-object in.... with a reference to the following line:
$bf_result = $this->bf_connect->query($this->bf_query);
Anybody got any suggestions?
Thanks!
|