I have taken over this code/website from a previous developer and am just getting more in depth with PHP and SQL. So I need some help, after much searching I have not found a similar issue.
I am receiving this error –
Call to a member function [B]query()[B]inc_sql.php on line 27
The code snippet-
<?PHP
//global $dbc;
$dbc = new DBI;
if (realpath(__FILE
class DBI
{
public $dbconn, $nfreed;
private $result, $threads;
[INDENT][INDENT]function __construct()
{
if(basename($_SERVER[‘SCRIPT_NAME’])==”message.php” && $
$this->nfreed=false;
$sqlhost = “IP”;
//$sqlhost = “localhost”;
@$this->dbconn = new mysqli($sqlhost, “user”, “password”, “database”);[/INDENT][/INDENT]
[INDENT][INDENT]if(mysqli_connect_errno()) header(“Location: message.php?error=sqlserver”);
//die(“Critical Error: “.mysqli_connect_error());
}
[/INDENT][/INDENT]
[INDENT][INDENT]function query($sql, $flag = MYSQLI_STORE_RESULT)
{
//echo(“<p>”.$sql.”</p>”);
if($this->nfreed) {$this->free();}
[B] if(!$this->result = $this->dbconn->query($sql)) header(“Location: message.php?error=sqlcmd&errno=”.$this->dbconn->errno);
//die(“<pre>Mysql Error: “.$this->dbconn->error.”</pre>”);
$this->nfreed=true;
return $result;
}[/INDENT][/INDENT]
[INDENT][INDENT] function get_threads() {
global $threads;
if($threads==””){
ereg (“Threads: (…)”, $this->dbconn->stat(), $regs);
$threads = trim($regs[1]);
}
return $threads;
} [/INDENT][/INDENT]
Any help is greatly appreciated.