I'm using mysqli for a function, and I'm getting an error, Fatal error: Call to a member function query() on a non-object in /home/u250000297/public_html/forum/system/db.php on line 46 I've tried different things, but I just get different errors, what am I doing wrong and where is my error?
Code lines 45-51:
function fetch($query) {
$sql = $mysqli->query($query);
$result = $sql->fetch_array(MYSQLI_BOTH);
return $result;
$sql->free();
}
Here's my previous attempt and error : Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/u250000297/public_html/forum/system/db.php on line 46 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/u250000297/public_html/forum/system/db.php on line 47 Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/u250000297/public_html/forum/system/db.php on line 46 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/u250000297/public_html/forum/system/db.php on line 47
Code, lines 45-51:
function fetch($query) {
$sql = mysqli_query($mysqli, $query);
$row = mysqli_fetch_array($sql, MYSQLI_BOTH);
return $row;
mysqli_free_result($row);
}
Connection:
$mysqli = mysqli_connect($this->host,$this->username,$this->password);
mysqli_select_db( $mysqli,$this->database );
if ($mysqli->connect_error) {
trigger_error('Database connection failed: ' . $mysqli->connect_error, E_USER_ERROR);
}
fetchfunction?$mail = $db->fetch("SELECT * FROM " . $prefix . "_mail WHERE id = '$mail_id'");and$account = $db->fetch("SELECT * FROM accounts WHERE email = '$email' AND lpip = '$lpip'");